捕获F4功能键
vbscript中,如何捕获F4功能键?
[解决办法]
F4是定位地址栏,貌似捕获不到~
With CreateObject("InternetExplorer.Application") .Navigate "about:blank" Do Until .ReadyState = 4 Loop .Document.Write "<body onkeyup=vbscript:document.write(chr(window.event.keycode))>" .Visible = True MsgBox "关闭ie" .QuitEnd With
[解决办法]
捕获要用onkeydown,它在3个事件中是第一位的。
Set oIE = WScript.CreateObject("InternetExplorer.Application","Event_") oIE.Navigate "about:blank" Do WScript.Sleep 200 Loop Until oIE.ReadyState = 4 'oIE.Document.Write "<body onKeyDown='alert(event.keyCode);'>" oIE.Visible = 1Set oIE.Document.Body.onKeyDown = GetRef("MySub") Do WScript.Sleep 200 Loop Sub MySub If oIE.Document.parentWindow.event.keyCode = 115 Then '这里的115用字符比较也可以 WScript.Echo "您按下了F4!" End IfEnd Sub Sub Event_onQuit oIE.Quit WScript.QuitEnd Sub