‘测试函数 PressESC "Windows Internet Explorer", "{ESCAPE}" '我们要处理的函数 Function PressESC(WindowTitle, KeyCommand) Set objShell = CreateObject("WScript.Shell") ‘定义一个WHS对象 If objShell.AppActivate(WindowTitle) Then '检测是否有我们要检测的Windows objShell.AppActivate WindowTitle ‘把窗口对焦 objShell.SendKeys KeyCommand '发送一个ESC键 End If End Function