Skip to content

Commit

Permalink
format code
Browse files Browse the repository at this point in the history
  • Loading branch information
Microtribute committed Sep 22, 2022
1 parent 1983917 commit 56739f4
Showing 1 changed file with 18 additions and 35 deletions.
53 changes: 18 additions & 35 deletions swap_primary_button.ahk
Original file line number Diff line number Diff line change
@@ -1,65 +1,48 @@
; ===============================================================================================================================
; Links.........: https://msdn.microsoft.com/en-us/library/ms646264.aspx
; https://msdn.microsoft.com/en-us/library/windows/desktop/ms646264.aspx
; ===============================================================================================================================
; Swap:
; 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.
;
; Return
; If the meaning of the mouse buttons was reversed previously,
; before the function was called, the return value is nonzero.
; If the meaning of the mouse buttons was not reversed,
; the return value is zero.
SwapMouseButton(Swap)
{
return DllCall("user32.dll\SwapMouseButton", "UInt", Swap)
}

ChangeCursorScheme(Scheme){
KeyNames := ["Arrow", "Help", "AppStarting", "Wait", "Crosshair", "IBeam", "NWPen", "No", "SizeNS", "SizeWE", "SizeNWSE", "SizeNESW", "SizeAll", "UpArrow", "Hand", "Pin", "Person"]
KEYpath := "HKEY_CURRENT_USER\Control Panel\Cursors"
SPI_SETCURSORS := 0x0057

RegRead, SchemeVals, HKEY_CURRENT_USER\Control Panel\Cursors\Schemes, %Scheme%
ChangeCursorScheme(Scheme)
{
KeyNames := ["Arrow", "Help", "AppStarting", "Wait", "Crosshair", "IBeam", "NWPen", "No", "SizeNS", "SizeWE", "SizeNWSE", "SizeNESW", "SizeAll", "UpArrow", "Hand", "Pin", "Person"]
KEYpath := "HKEY_CURRENT_USER\Control Panel\Cursors"
SPI_SETCURSORS := 0x0057

RegRead, SchemeVals, HKEY_CURRENT_USER\Control Panel\Cursors\Schemes, %Scheme%

if(!SchemeVals){
RegRead, SchemeVals, HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Control Panel\Cursors\Schemes, %Scheme%
}

if(!SchemeVals){
RegRead, SchemeVals, HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Control Panel\Cursors\Schemes, %Scheme%
}
SchemeVals := StrSplit(SchemeVals, ",")

SchemeVals := StrSplit(SchemeVals, ",")

if(SchemeVals.Length() > 0){
RegWrite, Reg_SZ, %KEYpath%, , %Scheme%
}
if(SchemeVals.Length() > 0){
RegWrite, Reg_SZ, %KEYpath%, , %Scheme%
}

for index, key in KeyNames {
val := SchemeVals[index]
RegWrite, Reg_Expand_SZ, %KEYpath%, %key%, %val%
}

DllCall("SystemParametersInfo", "UInt", SPI_SETCURSORS, "UInt", "0", "UInt", 0, "UInt", "0")
DllCall("SystemParametersInfo", "UInt", SPI_SETCURSORS, "UInt", "0", "UInt", 0, "UInt", "0")
}

Toggle()
{
buttonState := SwapMouseButton(1)

if (buttonState <> 0) ; Currently using left hand
if (buttonState <> 0) ; Currently using left hand
{
buttonState := SwapMouseButton(0)
ChangeCursorScheme("Windows Aero")
}
else ; Currently right hand (dominant hand)
else ; Currently right hand (dominant hand)
{
ChangeCursorScheme("Windows XI Aero Left Handed")
}
}

; ===============================================================================================================================

#F12::
Toggle()

0 comments on commit 56739f4

Please sign in to comment.