Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • December 06, 2016, 08:17:17 AM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: vs2008 express vc++ has anyone gotten RegisterHotKey to use mouse?  (Read 2814 times)

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,285
    • View Profile
    • Miles Ahead Software
    • Donate to Member
vs2008 express vc++ has anyone gotten RegisterHotKey to use mouse?
« on: September 11, 2010, 02:33:21 AM »
I know AutoIt3 is written in C++ and it doesn't accommodate mouse hotkeys the way ahk does. I'm wondering if the reason is that vc++ RegisterHotKey doesn't, if you use any mouse virtual keys. At least I couldn't get one to work with an hour of effort.  The keyboard keys work fine with WinKey or Alt or whatever.  But any mouse key, VK_LBUTTON or whatever, even if the RegisterHotKey call succeeds, press the hotkey and you get nadda.

Is there a secret or is it just broken?

Stoic Joker

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 6,296
    • View Profile
    • www.StoicJoker.com
    • Donate to Member
Re: vs2008 express vc++ has anyone gotten RegisterHotKey to use mouse?
« Reply #1 on: September 11, 2010, 10:34:59 AM »
Not sure exactly what you're after - Do you want/need to have a global system lever hot key registered? Or do you just want an application to look for/respond to A + B?

If it's application level you can use the below (snipped from an office project) in the message loop to get/capture/respond to keyboard or mouse events - combining them should be fairly straight forward.
Code: C++ [Select]
  1. //-------------------------------------+++--> END of Case WM_SYSCOMMAND
  2. //==================================================================================
  3.         case WM_NOTIFY: {
  4.                 LPNMLISTVIEW pnm = (LPNMLISTVIEW)lParam;
  5.                 //------------------------------------------------------------------------------+++-->
  6.                 if(((LPNMHDR)lParam)->code == LVN_KEYDOWN) { //======== Capture Key Strokes Here.  <<<
  7.                         hListView = GetWindow(hWnd, GW_CHILD); //-> ListView Child Control Handle
  8.                         LPNMLVKEYDOWN nmkey = (LPNMLVKEYDOWN)lParam;
  9.                         switch(nmkey->wVKey) {
  10.                           case VK_RETURN:
  11.                                 if((int)SendMessage(hListView, LVM_GETNEXTITEM, -1, LVNI_SELECTED) != -1) {
  12.                                         GetPartsOrderDetails(hListView, FALSE);  // Open Selected Order(s)
  13.                                  }else{ //----------------------------------//--+++-->
  14.                                         GetPartsOrderDetails(hListView, TRUE); // Give User Error Message
  15.                                 } break;
  16.                         }
  17.                 }
  18.                 //------------------------------------------------------------------------------+++-->
  19.                 if(((LPNMHDR)lParam)->code == NM_DBLCLK) { //========= Capture Mouse Clicks Here.  <<<
  20.                                 HWND hListView = GetWindow(hWnd, GW_CHILD); //-> ListView Child Control Handle
  21.  
  22.                         if((int)SendMessage(hListView, LVM_GETNEXTITEM, -1, LVNI_SELECTED) != -1) {
  23.                                 GetPartsOrderDetails(hListView, FALSE);  // Open Selected Order(s)
  24.                          }else{ //----------------------------------//--+++-->
  25.                                 GetPartsOrderDetails(hListView, TRUE); // Give User Error Message
  26.                         }
  27.                  }
  28.         } //------------------------------------------------+++--> END of Case WM_NOTIFY
  29. //==================================================================================

Sorry I couldn't find a combo'ed example - I know I've done it somewhere - So it can't be too hard.

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,285
    • View Profile
    • Miles Ahead Software
    • Donate to Member
Re: vs2008 express vc++ has anyone gotten RegisterHotKey to use mouse?
« Reply #2 on: September 11, 2010, 04:42:25 PM »
Since RegisterHotKey has VK keys for mouse buttons I thought I'd try them.  Even if they register without error, nothing happens when you click in combination with a modifier key.

I suspect it's dead otherwise it would be simple for AutoIt3 to use global mouse hotkeys. I know it's done in c++. That leads me to suspect the facility is either totally broken or convoluted enough to be unusable.

So again it looks like if you want global mouse hotkeys ahk is the choice. :)
I'd prefer coding with something with more scoping structure.. but it's tough to beat it for ease of mouse hotkey creation.

Just thought I'd post in case someone has done it.  But, if it was easy the AU3 guys would probably have done it already. :)