Correct sendkey for Ctrl + Shift + ;

荒凉一梦 提交于 2019-12-11 12:49:58

问题


I am trying to sed a keystroke in vb.net, and my code at the moment is SendKeys.Send("+^(;)")

But unfortunately it won't fire, could anyone tell me why?


回答1:


I don't recommend using sendkeys for anything really. Reason being that you never can guarantee the keystrokes will go where you intend. This is because you are simulating the input as if it were coming from the keyboard, which also ties up your keyboard.

I suggest instead you take the time and learn about the SendMessage api, or the PostMessage api. With these API's you can send messages to specific windows, regardless of what is going on with the keyboard. For instance, if you write a game bot using sendkeys, then you have to leave your computer alone while it runs and hope no unexpected windows pop open. Whereas if you learn the sendmessage api, then you can write a bot that runs in the background while you do other things with your computer.

here are some links to help:
pinvoke - sendmessage api
pinvoke - postmessage api
A list of windows messages constants/hex values/meanings
A nice description on how to use these api's



来源:https://stackoverflow.com/questions/31670128/correct-sendkey-for-ctrl-shift

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!