如何使用VB脚本将背景窗口模拟为活动状态?
我需要将一些键码命令发送到某个后台窗口(我知道相关的VB函数),但它只在窗口处于活动状态时才有效.如果窗口真的有效,我无法在前台做任何事情.
那么无论如何都要将窗口模拟为活动状态?
是的,请看这个例子
Dim oShell Set oShell = CreateObject("WScript.Shell") 'bring the window to front 'title must be exactly what you see in the titlebar of the window oShell.AppActivate "title of your window" WScript.Sleep 500 'give the window the time to activate,time is in miliseconds oShell.SendKeys "{ENTER}" 'you can send keystrokes to this window Set oShell = nothing
如果你想最小化那个窗口,你可以发送击键来做到这一点,但这取决于语言,所以首先手动尝试.以下命令从miNimize发送击键Alt(%)空格和N.尝试在窗口中按下Alt-Space键以获取控制它的菜单
oShell.SendKeys "(% )N"