Variable is not set somehow Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
tuangd
Posts: 5
Joined: 14 Aug 2020, 05:06

Variable is not set somehow

Post by tuangd » 23 Sep 2022, 02:46

I have this script to toggle the mouse wheel speed between the normal speed and the new speed. (I am testing the script with only the WheelUp for now.)

Code: Select all

NewWheelSpeed := 10
toggle := False
F18::toggle:=!toggle
WheelUp::
If (toggle)
	SendInput, {WheelUp, %NewWheelSpeed%}
Else
	SendInput, {WheelUp}
Return
And the only thing that is not working is the variable NewWheelSpeed
This is what shows in the Global Variables view in AHK windows

Code: Select all

NewWheelSpeed[0 of 0]:
I am not sure what I did wrong.
Any help or pointer would be much appreciated.
Thank you so much in advance.

lexikos
Posts: 9690
Joined: 30 Sep 2013, 04:07
Contact:

Re: Variable is not set somehow  Topic is solved

Post by lexikos » 23 Sep 2022, 03:30

My educated guess is that this code is part of a larger script, and NewWheelSpeed := 10 is not in the auto-execute section.

FAQ: Why do some lines in my script never execute?

This is a non-issue with AutoHotkey v2, because even if you explicitly end the "auto-execute section" (which is not necessary with v2), #Warn Unreachable is enabled by default. (Of course, you can enable that in v1.1.33+ as well, to avoid running into this issue again.)

tuangd
Posts: 5
Joined: 14 Aug 2020, 05:06

Re: Variable is not set somehow

Post by tuangd » 23 Sep 2022, 03:51

lexikos wrote:
23 Sep 2022, 03:30
My educated guess is that this code is part of a larger script, and NewWheelSpeed := 10 is not in the auto-execute section.
Yes! Thank you so much. You are correct. I moved the variable assign lines on top of everything and it's now working.
Cheers!!! :dance:

Post Reply

Return to “Ask for Help (v1)”