[Solved I guess] SetSystemCursor no longer working on Windows 10

Get help with using AutoHotkey and its commands and hotkeys
User avatar
berban
Posts: 93
Joined: 14 Apr 2014, 03:20

[Solved I guess] SetSystemCursor no longer working on Windows 10

26 Aug 2017, 19:28

I've been using this code https://autohotkey.com/board/topic/3260 ... em-cursor/ for years and it's worked beautifully. But on my windows 10 computer it no longer seems to change the cursor.

Here's some other information that might be helpful to someone smarter than me:
  • I regularly use the exact same script and AutoHotkey version on a windows 7 machine at my work and it works fine. I'm using system cursors not custom cursors.
  • The two DLLCalls in the code, SetSystemCursor and CopyIcon, both return nonzero values (on the Windows 10 machine) which means they completed successfully.
  • I am using AutoHotkey Unicode x64 (on both the Windows 7 and the Windows 10), but also tried it with all the other versions of AutoHotkey and even basic, with no success.
  • SetSystemCursor has been broken on my windows 10 machine for a while, but I do think it used to work. It's possible it stopped working around the time of the creator's update.
Thanks for reading!
Last edited by berban on 26 Aug 2017, 23:04, edited 1 time in total.
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: SetSystemCursor no longer working on Windows 10?

26 Aug 2017, 20:24

Hi, berban, I am using the SetSystemCursor() and RestoreCursors() with AHK 1.1.26.01 on Win 10 Version 1703 (OS Build 15063.540 That's Creator's Update I think).

Code: Select all

#SingleInstance Force

~MButton::SetSystemCursor()
~MButton Up::RestoreCursors()

SetSystemCursor()
{
	IDC_SIZEALL := 32646
	CursorHandle := DllCall( "LoadCursor", Uint,0, Int,IDC_SIZEALL )
	Cursors = 32512,32513,32514,32515,32516,32640,32641,32642,32643,32644,32645,32646,32648,32649,32650,32651
	Loop, Parse, Cursors, `,
	{
		DllCall( "SetSystemCursor", Uint,CursorHandle, Int,A_Loopfield )
	}
}

RestoreCursors()
{
	SPI_SETCURSORS := 0x57
	DllCall( "SystemParametersInfo", UInt,SPI_SETCURSORS, UInt,0, UInt,0, UInt,0 )
}
This script works fine for me. It is taken without changes from the linked post in the old forum. Is that the same thing you use?
If no, there might be some reason to look closely at CopyIcon, which is not used here.
User avatar
berban
Posts: 93
Joined: 14 Apr 2014, 03:20

Re: SetSystemCursor no longer working on Windows 10?

26 Aug 2017, 23:03

Nope, that code doesn't work for me either :| I was running AHK 1.1.25 and upgraded to 26 just to be safe. On windows, I'm 1 update behind at 15063.502 but either way they're both creator's update.

Guess there's something wrong with my computer then. Thanks for the confirmation! :D
Lindice

Re: [Solved I guess] SetSystemCursor no longer working on Windows 10

16 Mar 2018, 08:33

Hi all,
I'm not using autohotkey but found this topic via the "SetSystemCursor", "Windows 10" and "no longer working" keywords.
I experience exactly the same problem with a winforms C# development. Since approximatively the creators update, SetSystemCursor has stopped changing the windows cursor. I use a syntax like this one:
private const uint OCR_WAIT = 32514;
private const uint OCR_HELP = 32651;
SetSystemCursor(LoadCursor(IntPtr.Zero, (int)OCR_HELP), OCR_WAIT);
The compiled program works fine under Windows 7, 8.1 and older versions of Windows 10 - cursor change when I want it to - but no more on recent windows 10 versions. So maybe this isn't just your computer and maybe your guess is wrong when you write subject is solved :-)
Any solution / trick / workaround welcome!
Lindice
User avatar
berban
Posts: 93
Joined: 14 Apr 2014, 03:20

Re: [Solved I guess] SetSystemCursor no longer working on Windows 10

16 Mar 2018, 22:50

Hi Lindice,
It has actually started working again from time to time for me. I haven't counted exactly the proportion of time it works, but I'd say probably 50% of the time the cursor is successfully changing, especially after I reboot the computer.
Unfortunately I don't see any rhyme or reason to it, and I haven't changed my code at all, so I don't think that will be of much help to you. But it's definitely odd.
User avatar
Flipeador
Posts: 1173
Joined: 15 Nov 2014, 21:31
GitHub: Flipeador
Location: Argentina
Contact:

Re: [Solved I guess] SetSystemCursor no longer working on Windows 10

17 Mar 2018, 09:24

Code: Select all

SetSystemCursor("SIZEALL")
MsgBox
SetSystemCursor()
ExitApp


SetSystemCursor(Cursor := "")
{
    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}

    If (Cursor == "")
        Return DllCall("User32.dll\SystemParametersInfoW", "UInt", 0x0057, "UInt", 0, "Ptr", 0, "UInt", 0)
    Cursor := InStr(Cursor, "3") ? Cursor : Cursors[Cursor]

    Local hCursor
    For Each, ID in Cursors
    {
        hCursor := DllCall("User32.dll\LoadImageW", "Ptr", 0, "Int", Cursor, "UInt", 2, "Int", 0, "Int", 0, "UInt", 0x00008000, "Ptr")   ; 2 = IMAGE_CURSOR | 0x00008000 = LR_SHARED
        hCursor := DllCall("User32.dll\CopyIcon", "Ptr", hCursor, "Ptr")
        DllCall("User32.dll\SetSystemCursor", "Ptr", hCursor, "UInt",  ID)
    }
} ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms648395(v=vs.85).aspx
?
Windws 1♂ Pro 64-Bits I make scripts for AHKv2 (my v2 compiler) & WIN_7+ Spanish Argentina
(If any of my code written for v2 has stopped working, send me a private message. I appreciate that you correct my English.)

Return to “Ask For Help”

Who is online

Users browsing this forum: artur1884, Google [Bot], Rohwedder, zavf and 33 guests