-1

如何使用 VB 脚本将背景窗口模拟为活动状态?

我需要将一些键码命令发送到某个背景窗口(我知道相关的 VB 函数),但它仅在窗口处于活动状态时才有效。如果窗口真的是活动的,我不能在前台做任何事情。

那么无论如何都要将窗口模拟为活动状态吗?

4

1 回答 1

0

是的,看这个例子

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" 
于 2012-06-11T08:28:25.907 回答