简体   繁体   中英

How send keystrokes using internet explorer?

What I need, is to trigger a keyboard shortcut on the client. If nothing appends then the user know that my software will work and that he can download it (as the page text explain) .
However the shortcut is confusing because several keys have the same name. It would be nice to trigger the ᴡindows® shortcut by clicking on a link.

So I don't want to simulate keypress event but really pull the keys remotely. ActiveX seems to be the solution, however it seems it is as trivial as using Flash Player.

I've read on an Stack Overflow anwser internet explorer have JavaScript extensions allowing some kind of OS control. But I can't find that similar Stack Overflow post again.

This isn't possible. Sorry.

(If it were, that would pose a huge security risk. Consider what could happen if a web page could trigger Win+R and type in a command!)

This is some sample code.

Use as you wish :)

Set Elements = IEDoc.getElementsByClassName("REQ")(0)
Elements.Value = 10001
Set objWSS = CreateObject("WScript.Shell")
Elements.Focus
objWSS.SendKeys "^{TAB}"
DoEvents
objWSS.SendKeys ("{DOWN}")
DoEvents
objWSS.SendKeys ("{TAB}{RIGHT}")
DoEvents

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM