global variable not working bug

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Nikiwonno
Posts: 8
Joined: 29 Jun 2022, 10:44

global variable not working bug

Post by Nikiwonno » 14 Aug 2022, 13:01

I can substitute b with u but I can't substitute a with 555? What is happening, is there something wrong with the 555 value?

Code: Select all


b::
	Send u
	Return

c:=555


function2(){

	
	global c
	Send %c%
	
}



a::

	function2()
	
	Return


gregster
Posts: 9014
Joined: 30 Sep 2013, 06:48

Re: global variable not working bug

Post by gregster » 14 Aug 2022, 13:08

No, it's a matter of script logic, and flow of execution.

The line c:=555 is currently unreachable, it never gets executed, the variable doesn't get assigned.
See auto-execute section: https://www.autohotkey.com/docs/Scripts.htm#auto

Put the line c:=555 at the top of your script, or into some subroutine which gets executed before you actually evaluate the variable.

Post Reply

Return to “Ask for Help (v1)”