Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Loading cursors from compiled exe...



  • Please log in to reply
1 reply to this topic
gwarble
  • Members
  • 624 posts
  • Last active: Aug 12 2016 07:49 PM
  • Joined: 23 May 2009
Hey all,
I'm trying to load cursors that i've added to the compiled script as a resource (by first adding them to the SC.bin via Resource Hacker) and now i want to load and use them via LoadCursor, the goal being to not write the cursors to disk... for EitherMouse

I can't quite figure out how to enumerate them or apply them... i'm using info from here and other threads:
<!-- l --><a class="postlink-local" href="http://www.autohotkey.com/community/viewtopic.php?f=2&t=35600">viewtopic.php?f=2&t=35600</a><!-- l -->

i'll post some example code, unless someone has a quick function they use for this...
thanks
- gwarble

gwarble
  • Members
  • 624 posts
  • Last active: Aug 12 2016 07:49 PM
  • Joined: 23 May 2009
✓  Best Answer
ok i got it working by using pointer to reference name... not the numeric id i would prefer...

so i added cursors to AutoHotkeySC.bin with resource names "ARROWXP" and "HANDXP", with ResHacker
#Persistent
Compile("Run")

 ModuleHandle := DllCall("GetModuleHandleA", Str,A_ScriptFullPath)
 str=ARROWXP
 CursorHandleArrow  := DllCall( "LoadCursor", Uint,ModuleHandle, Int, &str )
 str=HANDXP
 CursorHandleHand  := DllCall( "LoadCursor", Uint,ModuleHandle, Int, &str )
 cx:=cy:=32
Return

1::
 CursorHandle := DllCall( "CopyImage", uint, CursorHandleArrow, uint, IMAGE_CURSOR:=0x2, int,cx, int,cy, uint,0 )
 DllCall( "SetSystemCursor", Uint, CursorHandle, Int, OCR_NORMAL:=32512 )
Return

2::
 CursorHandle := DllCall( "CopyImage", uint, CursorHandleHand, uint, IMAGE_CURSOR:=0x2, int,cx, int,cy, uint,0 )
 DllCall( "SetSystemCursor", Uint, CursorHandle, Int, OCR_NORMAL:=32512 )
Return

~Esc::ExitApp
press 1 and 2 to change cursor

Compiled CursorTest.exe
CursorTest.ahk
SC.Bin file
Compile.ahk


if you don't want to use compile(), backup your SC.bin and use this one, and comment out the Compile("Run") line