

I've left out RestoreCursors as I think it should be seperate.

This covers nearly everything in a single function. To restore system cursors use SystemParametersInfo/SPI_SETCURSORS:ĭllCall( "SystemParametersInfo", UInt,SPI_SETCURSORS, UInt,0, UInt,0, UInt,0 ) Reload the system cursorsĮxample script: The following changes the cursor while the MButton is down, and restores it on release.ĭllCall( "SystemParametersInfo", UInt,SPI_SETCURSORS, UInt,0, UInt,0, UInt,0 ) ModuleHandle := DllCall("GetModuleHandleA", Str,Module)ĬursorHandle := DllCall( "LoadImageA", Uint,ModuleHandle, Str,Cursor, Uint,IMAGE_ICON, Int,cx, Int,cy, UInt,0x10 ) If anyone knows how to use MAKEINTRESOURCE macro within DllCall do post. Here we need GetModuleHandle to get a handle for LoadImage, and MAKEINTRESOURCE to load a resource by ordinal. It may also be possible to load a cursor or icon from a DLL or EXE file. The result after a resize via CopyImage isn't as nice even with the LR_COPYFROMRESOURCE option.ĬursorHandle := DllCall( "LoadImageA", UInt,0, Str,Image, UInt,IMAGE_ICON, Int,cx, Int,cy, UInt,0x10 ) Note: LoadCursorFromFile will load other size icons and cursors but it seems to force the system settings onto it as it loads. I also tried this with multi icon and it seems to always load the largest icon. I used this method to load a 48x48 icon when my system is set to 32x32.

We can use LoadImage instead of LoadCursorFromFile to load non-standard size icons and cursors. This step is optional:ĬursorHandle := DllCall( "CopyImage", uint,CursorHandle, uint,IMAGE_CURSOR, int,cx, int,cy, uint,0 ) We can change the size of the cursor with CopyImage, although this method stretches it so the end look may not be satisfactory. You can also load an icon file here:ĬursorHandle := DllCall( "LoadCursorFromFile", Str,Cursor ) If you want to load a cursor from a file, use LoadCursorFromFile instead. Here I've used IDC_SIZEALL:ĬursorHandle := DllCall( "LoadCursor", Uint,0, Int,IDC_SIZEALL ) To load a system cursor use LoadCursor, which returns a handle to use in SetSystemCursor. The first thing is decide what kind of cursor to use - a system cursor, or a cursor loaded from a file? It is also possible to load a cursor from within a script, see Crazy Scripting : Include an Icon in your script. I thought I'd write a guide to hopefully make this more accessible to others.
