changing cursors

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
sttrebo
Posts: 68
Joined: 27 Jan 2014, 12:31

changing cursors

31 Oct 2017, 10:17

hi-
I'm working on a script that helps me populate a text file. I was hoping to have the text select cursor change when the hotkey is active. i.e., change to something obvious or (different cursor) to show that the hotkey is active then when i exit the script, the cursor changes back. thru searching the forums i found a small script that changes the normal select cursor to a different one.

Code: Select all

f1::SetCursor(32646)
f2::RestoreCursor()

SetCursor(cursorId,replaceID=32512)
{
	CursorHandle := DllCall( "LoadCursor", Uint,0, Int,cursorId)
	DllCall( "SetSystemCursor", Uint, CursorHandle, Int,replaceID)
}

RestoreCursor() 
{
	DllCall( "SystemParametersInfo", UInt,0x57, UInt,0, UInt,0, UInt,0 )
}
this works fine for the system cursor, but i want to change the text select cursor. does anyone know the parameter for the text select cursor?

thanks
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: changing cursors

31 Oct 2017, 10:28

That would probably be replaceID:=32513, see LoadCursor (MSDN), specifically, IDC_IBEAM.
Cheers.
sttrebo
Posts: 68
Joined: 27 Jan 2014, 12:31

Re: changing cursors

31 Oct 2017, 10:42

perfect, thanks
sttrebo
Posts: 68
Joined: 27 Jan 2014, 12:31

Re: changing cursors

31 Oct 2017, 11:16

another quick related question:
the cursor ID #'s, is there a cheatsheet for the different ID #'s?
i see this document
https://msdn.microsoft.com/en-us/librar ... s.85).aspx

is there a reference for all of the stock cursors available (windows10)? not by file name but by ID #..
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: changing cursors

31 Oct 2017, 11:45

I do not know. The values under the id paramter in your link (SetSystemCursor function), that is, OCR_XXX, is what I would expect are the available standard cursors.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: changing cursors

31 Oct 2017, 12:15

From WinUser.h:

Code: Select all

/*
 * Standard Cursor IDs
 */
#define IDC_ARROW           MAKEINTRESOURCE(32512)
#define IDC_IBEAM           MAKEINTRESOURCE(32513)
#define IDC_WAIT            MAKEINTRESOURCE(32514)
#define IDC_CROSS           MAKEINTRESOURCE(32515)
#define IDC_UPARROW         MAKEINTRESOURCE(32516)
#define IDC_SIZE            MAKEINTRESOURCE(32640)  /* OBSOLETE: use IDC_SIZEALL */
#define IDC_ICON            MAKEINTRESOURCE(32641)  /* OBSOLETE: use IDC_ARROW */
#define IDC_SIZENWSE        MAKEINTRESOURCE(32642)
#define IDC_SIZENESW        MAKEINTRESOURCE(32643)
#define IDC_SIZEWE          MAKEINTRESOURCE(32644)
#define IDC_SIZENS          MAKEINTRESOURCE(32645)
#define IDC_SIZEALL         MAKEINTRESOURCE(32646)
#define IDC_NO              MAKEINTRESOURCE(32648) /*not in win3.1 */
#if(WINVER >= 0x0500)
#define IDC_HAND            MAKEINTRESOURCE(32649)
#endif /* WINVER >= 0x0500 */
#define IDC_APPSTARTING     MAKEINTRESOURCE(32650) /*not in win3.1 */
#if(WINVER >= 0x0400)
#define IDC_HELP            MAKEINTRESOURCE(32651)
#endif /* WINVER >= 0x0400 */

...

/*
 * OEM Resource Ordinal Numbers
 */

...

#define OCR_NORMAL          32512
#define OCR_IBEAM           32513
#define OCR_WAIT            32514
#define OCR_CROSS           32515
#define OCR_UP              32516
#define OCR_SIZE            32640   /* OBSOLETE: use OCR_SIZEALL */
#define OCR_ICON            32641   /* OBSOLETE: use OCR_NORMAL */
#define OCR_SIZENWSE        32642
#define OCR_SIZENESW        32643
#define OCR_SIZEWE          32644
#define OCR_SIZENS          32645
#define OCR_SIZEALL         32646
#define OCR_ICOCUR          32647   /* OBSOLETE: use OIC_WINLOGO */
#define OCR_NO              32648
#if(WINVER >= 0x0500)
#define OCR_HAND            32649
#endif /* WINVER >= 0x0500 */
#if(WINVER >= 0x0400)
#define OCR_APPSTARTING     32650
#endif /* WINVER >= 0x0400 */
Also, I wrote this about cursors:

documentation - Indentifying the the type of the current cursor in autohotkey - Stack Overflow
https://stackoverflow.com/questions/413 ... autohotkey
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
sttrebo
Posts: 68
Joined: 27 Jan 2014, 12:31

Re: changing cursors

31 Oct 2017, 12:26

thanks, gives me a bit more to play with. I appreciate the help from both of you.
In my code in post #1, I reference the cursor ID#. If I wanted to use a custom cursor file, is there an easy tweak to make that work?
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: changing cursors

31 Oct 2017, 12:35

If I recall correctly, there is an example here, loadpicturetype.
sttrebo
Posts: 68
Joined: 27 Jan 2014, 12:31

Re: changing cursors

31 Oct 2017, 12:50

cool, thanks. gives me something to play around with this weekend...

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 76 guests