Hiding Cursor While Running Script

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
cleetz
Posts: 30
Joined: 04 Feb 2023, 15:09

Hiding Cursor While Running Script

Post by cleetz » 29 Feb 2024, 06:23

Hello. I have this code where it does indeed hide the cursor, but it wont execute the rest of my script afterward after hiding cursor. I wanted to have this in a separate script so I can just toggle it, then turn my other script on. However, when I turn my other script on , it unhides the cursor again. I suppose I could just unplug the mouse from the computer, as that technically hides the cursor, but I'd rather not do that everytime as its bad for the hardware. Heres my code:

Code: Select all

SystemCursor(0) ; This will hide the cursor when the script starts


SystemCursor(OnOff=1) {
    if (OnOff == 1)
    {
       DllCall("ShowCursor", Int,1)
    }
    else
    {
       MouseGetPos, , , hwnd
       Gui Cursor:+Owner%hwnd%
       DllCall("ShowCursor", Int,0)
    }
}



Toggle := 0 ; 0 means cursor is shown, 1 means hidden
F1:: ; F1 to pause and resume cursor visibility
    Toggle := !Toggle
    SystemCursor(Toggle)
Return

looking to incorporate this into my main script where, when I press ESC to pause the script, it also toggles off the cursor hide, then hides it again when i unpause and the script begins running again. Thanks for any advice

User avatar
boiler
Posts: 17404
Joined: 21 Dec 2014, 02:44

Re: Hiding Cursor While Running Script

Post by boiler » 29 Feb 2024, 06:29

If you’ve tried to combine this your other script and it didn’t work, I suspect it is because your other script has an auto-execute section, but you put that below the hotkey of this script, so it would never execute. See Structure of a Script.

Post Reply

Return to “Ask for Help (v1)”