[RESOLVED] about delay a procedure not a program
i have these code:
Code:
If blnEnter = False Then
'wait some milliseconds, but the rest of program must continue
RaiseEvent MouseHover(mbMouseButton, skShift, MousePos.x, MousePos.y)
End If
before raiseevent, i must put a delay with same milliseconds, but these delay can't pause the project only these procedure.
i try use the timer but doesn't work, because the intervale was ignored.
can anyone help me?
can i start the timer control interval from begin?
thanks
Re: about delay a procedure not a program
I guess you can use threading?
Wait.Sorry in what language?
Re: about delay a procedure not a program
For (single threaded) VB6 apps I think all you can really do is add DoEvents to your loops so the program doesn't appear frozen and still responds, so FWIW I'm not so sure this would help or not....
Code:
Option Explicit
Private Declare Function GetTickCount Lib "kernel32" () As Long
'.........
If blnEnter = False Then
'Delay raise event 100 milliseconds...
Call Delayed_Hover(100, mbMouseButton, skShift, MousePos.X, MousePos.Y)
End If
'......
Private Sub Delayed_Hover(mSecs As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim start As Long
Dim ending As Long
start = GetTickCount
Do
DoEvents
ending = GetTickCount
If (ending - start) >= mSecs Then Exit Do
Loop
RaiseEvent MouseHover(Button, Shift, X, Y)
End Sub
Re: about delay a procedure not a program
thanks but i continue with 1 problem.
is like the timer not always do the intervale... just see it...
thanks
Re: about delay a procedure not a program
Quote:
Originally Posted by sapator
I guess you can use threading?
Wait.Sorry in what language?
visual basic 6
Re: about delay a procedure not a program
Quote:
Originally Posted by joaquim
visual basic 6
If a timer doesn't fire at it's set interval then other running code is probably taking longer to complete then the timer interval is set for. You might want to run a code profiler to see what sections of your code are taking the longest and make some adjustments. Or maybe look into VB6 multi-threading, there's some in the VB6 & earlier code bank.
Re: about delay a procedure not a program
Quote:
Originally Posted by Edgemeal
If a timer doesn't fire at it's set interval then other running code is probably taking longer to complete then the timer interval is set for. You might want to run a code profiler to see what sections of your code are taking the longest and make some adjustments. Or maybe look into VB6 multi-threading, there's some in the VB6 & earlier code bank.
(did you see my groupproject?)
sometimes the code is call in some milliseconds(but not the real) and in others is call in less than that milliseconds.
"Or maybe look into VB6 multi-threading, there's some in the VB6 & earlier code bank" where is it?
thanks
Re: about delay a procedure not a program
ok i finaly resolve...
i use(again) 1 timer...
the MousePos.x and MousePos.y is the actual position
the lngOldMouseX and lngOldMouseY are the last position saved.
Code:
If MousePos.x = lngOldMouseX And MousePos.y = lngOldMouseY And blnEnter = False Then
RaiseEvent MouseHover(mbMouseButton, skShift, MousePos.x, MousePos.y)
Else
lngOldMouseX = MousePos.x
lngOldMouseY = MousePos.y
End If
sims that the timer need more time that is need... maybe is about otherthing not finished, like you said.
thanks
Re: [RESOLVED] about delay a procedure not a program
Ya I looked at the code and ran it but have no clue what its supposed to do or could I really follow the flow of the code.
Glad you resolved it!
Re: [RESOLVED] about delay a procedure not a program
Quote:
Originally Posted by Edgemeal
Ya I looked at the code and ran it but have no clue what its supposed to do or could I really follow the flow of the code.
Glad you resolved it!
when you pass hover the GifAnimator image you can see the mouseevents activate... but when you stop the mouse in image, with some milliseconds, the mouseHover must activate...
thanks