• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 402
  • Last Modified:

Swap Mouse Buttons

Is there a way to swap the mouse buttons, like you can in the mouse control panel?  I know that there is a registry entry, but once edited, you have to restart windows to take effect. I dont want to do that, I want to do it right now  :)   is there a way to program that in C++\mfc?  thanks.
0
Nitro187
Asked:
Nitro187
  • 3
1 Solution
 
jkrCommented:
Simply use this Win32 API function (the following is taken from the MS online docs:

SwapMouseButton (Win32)

BOOL SwapMouseButton(fSwap)

BOOL fSwap;      /* reverse or restore buttons      */


The SwapMouseButton function reverses or restores the meaning of the left and right mouse buttons.

Parameter      Description

fSwap      Specifies whether the mouse button meanings are reversed or restored. If this parameter is
TRUE, the left button generates right-button messages and the right button generates
left-button messages. If this parameter is FALSE, the buttons are restored to their original
meanings.

Returns

If the meaning of the mouse buttons was reversed previously, before the function was called, the return value is
TRUE; otherwise, it is FALSE.

Comments

Button swapping is provided as a convenience to people who use the mouse with their left hands. The
SwapMouseButton function is usually called by Control Panel only. Although an application is free to call the
function, the mouse is a shared resource and reversing the meaning of its buttons affects all applications.


0
 
jkrCommented:
Ooops, sorry - this one seems to be a duplicate: See http://www.experts-exchange.com/Computers/Programming/Languages/C++/Q.10184017 (posted on  Saturday, July 17 1999 - 10:17PM PDT) - anyway, both naveenkohli as WxW gave a correct answer...
0
 
Nitro187Author Commented:
Thanks  :D
0
 
jkrCommented:
Err - my pointer to the duplicate was meant that you should grant _them_ the points, as they were earlier...
0

Featured Post

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now