Sendkeys and Sleep/Wait

H

hoffj

I am positive that I remember that Sendkeys had a sleep option that could be
used to allow program execution to continue while I specify the amount of
time I wish to wait in milliseconds. I use "ECHO.Wscript.sleep
1000>>_TEMP.VBS" whenever I automate something using a batch file and it
works great, but I forget how the sleep syntax is for vba coding. Any help
would be appreciated. I have also tried the following sleep function I found
in another post, but it will completely pause program execution.

Private Declare Sub sapiSleep Lib "kernel32" _
Alias "Sleep" _
(ByVal dwMilliseconds As Long)

Sub sSleep(lngMilliSec As Long)
If lngMilliSec > 0 Then
Call sapiSleep(lngMilliSec)
End If
End Sub
 
F

flavo

Here is an exmple. This will wait till the process you open is finished /
closed

http://www.scottandmichelle.net/scott/code/index2.mv?codenum=069

API CALLS

Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal _
hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" (ByVal _
dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal _
dwProcessID As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject _
As Long) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal _
dwMilliseconds As Long)

Dave.
 
H

hoffj

How would I implement this in vba. I know to put all of the code below into
it's own module, but what function/sub do I use when I want to call
wait/sleep feature.

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top