Home
Tutorials
Code Snippets
Code Samples
Downloads
Links

The Blog
Our Projects
About
Contact

::Add RageStorm to Favorites!::

The Blog | Our Projects | Guest Book | About | Contact

 
Code Snippet - Hotkeys
Author:Arkon
Category:Win32API
File Size:663 Bytes
Uploaded at:01-Mar-03 03:13:23 am
Description:
  Set a system-wide hot key which upon pressing will notify you by sending a message to your window procedure.
  
// The hWnd is the window which will be notified when the hotkey was pressed.

int hotkeyId1 = 1; // Every hotkey in a thread should have a unique ID...

// The window procedure should look something like this:
switch(msg)
{
 case HOTKEY:
  switch ((int)wParam)
  {
   case hotkeyId1:
    MessageBox(NULL, "Ctrl+Alt+F5 was hit", "Hotkey", MB_OK);
   break;
  }
 break;
.
.
}

// Add the hotkey:

// You can use MOD_CONTROL, MOD_ALT, MOD_SHIFT or MOD_WIN.
// Last variable is simply the VK.
if (RegisterHotkey(hWnd, hotkeyId1, MOD_CONTROL | MOD_ALT, VK_F5) == 0) {
 // Error
}


// Remove the hotkey:
UnregisterHotkey(hWnd, hotkeyId1);
NOTE:
Comments that will hurt anyone in any way will be deleted.
Don't ask for features, advertise or curse.
If you want to leave a message to the author use the contacts,
if you have any question in relation to your comments please use the forum.
Comments which violate any of these requests will be deleted without further
notice. Use the comment system decently.

Post your comment:
Name:
email:
Comment:
::Top 5 Tutorials::
Embedded Python[116832]
2D Rotated Rectangles Collision Detection[88945]
Keyboard Hook[77238]
UDP[65795]
HTTP Proxy[41186]

::Top 5 Samples::
2D ColDet Rotated Rectangles[11557]
PS2 Mouse Driver[6953]
Wave Format Player[5788]
Reading FAT12[5615]
CodeGuru[5355]


All rights reserved to RageStorm © 2009