Send global keystroke / fake a global hotkey from a Winforms application

大憨熊 提交于 2019-12-14 03:19:40

问题


For my current winforms win7 project I need to simulate some global hotkey presses.

I tried sending the keystrokes with SendMessage directly to the program interceptin the hotkeys, but that doesnt work. The program doesnt seem to handle incoming hotkeys when it's foccused / send directly to them.

How would I send simulated keypresses so that they get recognized as Global Hotkeys?

Thanks in advance!

EDIT: I dont want to Set hotkeys for my app, I want to trigger them in another application From my app. So my app will send Keystrokes somewhere, to be picked up by the other app. I dont know where to send them, sending them directly doesnt work


回答1:


You can use sendKeys:

SendKeys.Send("+^S");

This is for Ctrl+Shift+S

Check msdn: https://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.send(v=vs.110).aspx



来源:https://stackoverflow.com/questions/36207594/send-global-keystroke-fake-a-global-hotkey-from-a-winforms-application

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