cthonianmessiah
Programmer
I'm using API calls (SendInput mostly) to automate an external program through VBA, but the external program runs very slowly under the macro, and the problem seems to be that the macro is hogging all of the system resources even when waiting for a response.
The data is transmitted between the macro and the external app using the clipboard, so I actually have to check the clipboard periodically to determine if I am ready to continue.
I have a delay function that loops for a specified period of time to allow the external program to catch up, but it looks like continuous looping is using almost all of the available resources which I'd rather were allocated to the external program.
How can I use VBA to wait for a specified period of time without using excessive system resources? (My current compute-hogging delay function is included below.)
The data is transmitted between the macro and the external app using the clipboard, so I actually have to check the clipboard periodically to determine if I am ready to continue.
I have a delay function that loops for a specified period of time to allow the external program to catch up, but it looks like continuous looping is using almost all of the available resources which I'd rather were allocated to the external program.
How can I use VBA to wait for a specified period of time without using excessive system resources? (My current compute-hogging delay function is included below.)
Code:
Private Sub delay(msec As Long)
Dim inittime As Long
inittime = CLng(Timer * 100)
Do While CLng(Timer * 100) < inittime + msec
Loop
End Sub