Last active
October 20, 2018 06:57
-
-
Save ursi/133779423fb7f4445160703a2b031170 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setCursor(guiOrCont, cursor, options := 'n l r m'){ | |
static cursors := { | |
appstarting: 32650, | |
arrow: 32512, | |
cross: 32515, | |
hand: 32649, | |
help: 32651, | |
ibeam: 32513, | |
no: 32648, | |
sizeall: 32646, | |
sizenesw: 32643, | |
sizens: 32645, | |
sizenwse: 32642, | |
sizewe: 32644, | |
uparrow: 32516, | |
wait: 32514, | |
hide: 0, | |
} | |
changeCurs(cursor2){ | |
dllCall 'SetCursor', 'int', dllCall( | |
'LoadImageW', | |
'int', 0, | |
'int', cursors[cursor2], | |
'int', 2, | |
'int', 0, | |
'int', 0, | |
'int', 0x8000) | |
} | |
curCheckMove(wParam){ | |
static guiObjs := {} | |
if not guiObjs[guiOrCont] | |
guiObjs[guiOrCont] := {} | |
downFlags := guiObjs[guiOrCont] | |
if gFlagL | |
downFlags.lDown := cursor | |
if gFlagR | |
downFlags.rDown := cursor | |
if gFlagM | |
downFlags.mDown := cursor | |
mouseGetPos ,, win, cont | |
if type(guiOrCont) != 'gui' and win = guiOrCont.gui.hwnd and cont = guiOrCont.classNN | |
or type(guiOrCont) = 'gui' and win = guiOrCont.hwnd and not cont{ | |
if downFlags.lDown and wParam = 1 | |
changeCurs(downFlags.lDown) | |
else if downFlags.rDown and wParam = 2 | |
changeCurs(downFlags.rDown) | |
else if downFlags.mDown and wParam = 0x10 | |
changeCurs(downFlags.mDown) | |
else if nFlag | |
changeCurs(cursor) | |
} | |
} | |
curCheckClick(){ | |
mouseGetPos ,, win, cont | |
if type(guiOrCont) != 'gui' and win = guiOrCont.gui.hwnd and cont = guiOrCont.classNN | |
or type(guiOrCont) = 'gui' and win = guiOrCont.hwnd and not cont | |
changeCurs(cursor) | |
} | |
if options ~= 'i)n' | |
nFlag := 1 | |
local gFlagL, gFlagR, gFlagM | |
flags := {l: 0, r: 3, m: 6} | |
for flag, offset in flags | |
if options ~= 'i)' flag{ | |
regExMatch(options, flag '(\S+)', subOptions) | |
if not subOptions | |
loop 3 | |
onMessage 0x200 + offset + a_index, 'curCheckClick' | |
else{ | |
if subOptions.1 ~= 'i)d' | |
onMessage 0x201 + offset, 'curCheckClick' | |
if subOptions.1 ~= 'i)g'{ | |
gFlag%flag% := 1 | |
} | |
if subOptions.1 ~= 'i)u' | |
onMessage 0x202 + offset, 'curCheckClick' | |
if subOptions.1 ~= '2' | |
onMessage 0x203 + offset, 'curCheckClick' | |
} | |
} | |
onMessage 0x200, 'curCheckMove' | |
} |
When the mouse is moved there can be a bit of flickering back to the default arrow. I have no idea how to fix this (please let me know if you do) but it's not too bad.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
setCursor guiOrCont, cursor[, options]
guiOrCont
A GUI or GUI control object for which the cursor will change. If
guiOrCont
is a GUI object, then the cursor will only change when it's in the client area and not over a control.cursor
This is a string that represents one of the built-in Windows cursors. You can read more about them here. Use the part directly after
IDC_
. It also includeshide
, which will hide the cursor.options
Type:
String
n
:cursor
will be applied when the mouse is moved, even when mouse buttons are held down, provided that no other setting overrides this.l
,r
, andm
: These options all have the following sub-options:g
:cursor
will be applied when the mouse is moved and the specified button is being held down.d
:cursor
will be applied when the specified button is clicked down.u
:cursor
will be applied when the specified button is released.2
:cursor
will be applied when the specified button is double clicked and held down.Omitting all sub-options is equivalent to the sub-options
du2
, and omittingoptions
is equivalent ton l r m
(which changes the cursor at all times). Put spaces between the different options, but not between options and theirs sub-options, e.g.ldg ru m2
.