can't add +1 on a variable constantly

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
matsjts
Posts: 1
Joined: 01 Feb 2023, 14:55

can't add +1 on a variable constantly

Post by matsjts » 01 Feb 2023, 15:00

Code: Select all

Var := 0
som()
{
   Var++
send % Var
}
p:: ;
    som()
return
im a beginner with ahk, and idk what am i doing wrong. hope someone knows how to fix this


[Mod edit: Added [code][/code] tags. Please use them yourself when posting code.]

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

Re: can't add +1 on a variable constantly

Post by boiler » 01 Feb 2023, 15:55

You have a variable scope problem. The easiest fix is to make Var a global variable:

Code: Select all

global Var := 0

Post Reply

Return to “Ask for Help (v1)”