VBS窗口获取焦点,高手们请指教!

2025-01-03 07:39:52
推荐回答(2个)
回答1:

Dim WshShell
Set WshShell=WScript.CreateObject("WScript.Shell")
WshShell.Run "notepad"
WScript.Sleep 4000 "!这时把光标移到另外一个窗口
WshShell.AppActivate "无标题 - 记事本"
WScript.Sleep 500
WshShell.SendKeys"aadsfadfadbsvzxcv"

回答2:

改成这样就可以了
Dim WshShell
Set WshShell=WScript.CreateObject("WScript.Shell")
WshShell.Run "notepad"
WScript.Sleep 4000
WshShell.AppActivate "无标题 - 记事本"
WScript.Sleep 500
WshShell.SendKeys"aadsfadfadbsvzxcv"