07-04-2009, 05:47 PM
Function WaitForCursor
Function CursorCrc
How to use:
1. Create these 2 functions.
2. Create macro
Macro
Trigger F7
Run the macro when is displayed cursor you need. It displays a number in qm output. Use the number with WaitForCursor. Example:
Macro
;/
function ^waitmax cursorCrc [flags] ;;waitmax: 0 is infinite. flags: 1 wait for different cursor
;Waits for cursor (mouse pointer).
;waitmax - max number of seconds to wait. 0 is infinite.
;cursorCrc - value returned by CursorCrc function.
if(waitmax<0 or waitmax>2000000) end ES_BADARG
opt waitmsg -1
int wt(waitmax*1000) t1(GetTickCount) crc
rep
,crc=CursorCrc
,if(flags&1) if(crc!=cursorCrc) ret
,else if(crc=cursorCrc) ret
,
,0.2
,if(wt and GetTickCount-t1>=wt) end "wait timeout"
Function CursorCrc
;/
function#
;Returns CRC of current cursor's mask bitmap data.
;If fails, returns 0.
CURSORINFO ci.cbSize=sizeof(ci)
if(!GetCursorInfo(&ci) or ci.flags&CURSOR_SHOWING=0) ret
ICONINFO ii
if(!GetIconInfo(ci.hCursor &ii) or !ii.hbmMask) ret
if(ii.hbmColor) DeleteObject(ii.hbmColor)
__GdiHandle h=CopyImage(ii.hbmMask IMAGE_BITMAP 0 0 LR_COPYDELETEORG|LR_CREATEDIBSECTION)
BITMAP b
if(!GetObject(h sizeof(b) &b) or !b.bmBits) ret
ret Crc32(b.bmBits b.bmHeight*b.bmWidthBytes)
How to use:
1. Create these 2 functions.
2. Create macro
Macro
Trigger F7

Run the macro when is displayed cursor you need. It displays a number in qm output. Use the number with WaitForCursor. Example:
Macro