Alternative to appactivate (so SendKeys works in background) [duplicate]

☆樱花仙子☆ 提交于 2019-12-13 17:22:34

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!