0

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

ThomQ
  • 595
  • 2
  • 11
  • 32
  • 1
    Look at [this question](http://stackoverflow.com/questions/2450373/set-global-hotkeys-using-c-sharp) – Icemanind Mar 24 '16 at 18:37
  • Ahh, no I need to send a keystroke to another application, not my own. – ThomQ Mar 24 '16 at 18:39
  • Sure, doesn't work, it works at a lower level an you actually have to simulate key input. Use SendInput() instead. – Hans Passant Mar 24 '16 at 18:39
  • The program doesnt recognize the global hotkeys when focussed, when I press them manually. You think SendInput would work? – ThomQ Mar 24 '16 at 18:44

1 Answers1

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

Duan Xin
  • 11
  • 2