从Winforms应用程序发送全局按键/伪造全局热键 [英] Send global keystroke / fake a global hotkey from a Winforms application
问题描述
对于我当前的winforms win7项目,我需要模拟一些全局热键按下.
For my current winforms win7 project I need to simulate some global hotkey presses.
我尝试将带有SendMessage的击键直接发送到热键中的程序拦截器,但这不起作用.当该程序被聚焦/直接发送给它们时,该程序似乎不处理传入的热键.
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?
提前谢谢!
我不想为我的应用程序设置热键,我想在我的应用程序的另一个应用程序中触发它们.因此,我的应用程序会将击键发送到某个地方,以供其他应用程序接收.我不知道将它们发送到哪里,直接将它们发送不起作用
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
推荐答案
您可以使用sendKeys:
You can use sendKeys:
SendKeys.Send("+^S");
这是Ctrl + Shift + S
This is for Ctrl+Shift+S
检查msdn: 查看全文