My Technical Notes

Thursday, 15 April 2010

Swapping Mouse Buttons with AutoHotKey

To prevent repetitive strain injury, you may want to change the hand that you control your mouse with, frequently, like every hour or so. Therefore you will want a quick method of swapping the left and right mouse buttons because changing the mouse options from the Control Panel takes too long.

An additional requirement could be that you want the mouse buttons to be swapped natively without mouse click interception. The benefit of this would be that your mouse clicks are much faster and more reliable and this matters when playing games.

The only way of swapping mouse buttons without any overhead is to use the Win32 function SwapMouseButton:

Swapped := DllCall("SwapMouseButton", Int, 0)
if Swapped = 0
 DllCall("SwapMouseButton", Int, 1)

No comments: