I think I've gotten close by applying a few different codes into one code. However, for some reason the isMouseShown() function does not suspend when the crosshair is visible. Can you tell me why? Something is missing or not set up to detect the correct thing to Suspend.
Code: Select all
#MaxHotkeysPerInterval 200
SetBatchLines, -1
isMouseShown()
Gui, -MinimizeBox
Gui, Margin, 10, 10
Gui, Font, Bold, Consolas
Gui, Add, CheckBox, xm ym vED gCheckBox w200, Enable/Disable Script Hotkey:
Gui, Add, Hotkey, xm+200 yp-2 vHotkey w100 gApplyChanges, % Prev_Hotkey := "End"
Hotkey, End, CheckBoxH
Gui, Add, Text, xm yp+30 w50, Speed:
Gui, Add, Edit, xp+50 yp-2 vSpeed w250 Number, 10
Gui, Show
Hotkey, LButton, LeftButton, Off
Hotkey, LButton Up, LeftButtonUp, Off
Return
GuiClose:
ExitApp
isMouseShown()
{
StructSize := A_PtrSize + 16
VarSetCapacity(InfoStruct, StructSize)
NumPut(StructSize, InfoStruct)
DllCall("GetCursorInfo", UInt, &InfoStruct)
Result := NumGet(Info+Struct, 8)
if Result > 1
return 1
else
return 0
}
Loop
{
if isMouseShown() == 1
Suspend On
else
Suspend Off
Sleep 1
}
]::
GuiControlGet, Speed,, Speed
GuiControl,, Speed, % ++Speed
Return
[::
GuiControlGet, Speed,, Speed
GuiControl,, Speed, % --Speed
Return
LeftButton:
GuiControlGet, Speed,, Speed
SendInput, {LButton Down}
SetTimer, DragDown, % 10 / Speed
Return
LeftButtonUp:
SendInput, {LButton Up}
SetTimer, DragDown, Off
Return
DragDown:
GuiControlGet, Speed,, Speed
DllCall("mouse_event", "UInt", 0x01, "UInt", 0, "UInt", - (1 + Speed))
Return
CheckBoxH:
GuiControlGet, ED,, ED
GuiControl,, ED, % ED := !ED
Hotkey, LButton, % Stat := (ED) ? "On" : "Off"
Hotkey, LButton Up, % Stat
Return
CheckBox:
GuiControlGet, ED,, ED
Hotkey, LButton, % Stat := (ED) ? "On" : "Off"
Hotkey, LButton Up, % Stat
Return
ApplyChanges:
GuiControlGet, Hotkey,, Hotkey
Hotkey, % Prev_Hotkey, CheckBox, Off
Hotkey, % Prev_Hotkey := Hotkey, CheckBox, On
Return