问题
I have written this script and of course every 10 seconds the 'my program' window is activated to send the F9 key. However, what I'd like to do is send the F9 key every 10s to the 'my program' window without actually activating it as it interupts work on other windows/browsers. Will need it to run continuously during my day as a background process ideally. (the F9 key refreshes the screen)
Option Explicit
Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
Do
WshShell.AppActivate "my program"
WshShell.SendKeys "{F9}"
WScript.Sleep (1000 * 10)
Loop
回答1:
As Alex K. mentioned, SendKeys can only send keystrokes to the foreground window, so what you're asking simply is not possible with VBScript.
来源:https://stackoverflow.com/questions/43066674/alternative-to-appactivate-so-sendkeys-works-in-background