In my program(C++, WinAPI), I wanted to simulate pressing some existing hotkeys set in other running programs. I know there is a [**SendInput**](http://msdn.microsoft.com/en-us/library/ms646310%28v=VS.85%29.aspx) function which simulates the keyboard input, but it seemed too much work as it needs to create a lot of structures for the keys.

I was trying use [**SendMessage**](http://msdn.microsoft.com/en-us/library/ms644950%28v=vs.85%29.aspx) or **PostMessage** with HWND\_BROADCAST and WM\_HOTKEY parameters. Neither worked.

The code looks like this:

```
WORD hotkey = MAKEWORD(MOD_CONTROL, VK_SPACE); // Ctrl + Space

SendMessage( HWND_BROADCAST,
             WM_HOTKEY,
             (WPARAM)hotkey , 0);

```

Am I on the right track? or this should be done completely in a different way?