This variable has not been assigned a value

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
--kIWI--
Posts: 3
Joined: 18 May 2017, 20:36

This variable has not been assigned a value

19 Jul 2017, 22:15

This code is a mess, I wont lie but please help me.

Im making an AHK script to run with a popular script used by CSGO players, the script is returning an error "This variable has not been assigned a value Specificaly: CheckVar (a global variable)" and points to line 77

Code: Select all

#Warn
;Qiwi's Mod for Peans AHK script

Func1()

;Key binds
key_AK:="F4"
key_M4A1:="F6"
key_M4A4:="F7"
key_Famas:="F8"
key_Galil:="F9"
key_UMP:="F12"
key_AUG:="Home"
key_SG:="End"
key_RCoff:="F11"
key_Terminate:="F10"
key_shoot:="LButtCheckVar"
key_zoom:="LAlt"

CheckVar := 0
loop {
sleep 1
;Menu handling
if GetKeyState(key_AK)
{
CheckVar := true
}

if GetKeyState(key_M4A1)
{
CheckVar := true
}

if GetKeyState(key_M4A4)
{
CheckVar := true
}

if GetKeyState(key_Famas)
{
CheckVar := true
}

if GetKeyState(key_Galil)
{
CheckVar := true
}

if GetKeyState(key_RCoff)
{
CheckVar := true
}

if GetKeyState(key_UMP)
{
CheckVar := true
}

if GetKeyState(key_SG)
{
CheckVar := true
}

if GetKeyState(key_AUG)
{
CheckVar := true
}


if GetKeyState(key_RCoff)
{
CheckVar := false
}
Func1()
{
global CheckVar
if CheckVar
{
GetKeyState, IsClicked, LButton
if IsClicked = D
{
MouseGetPos, MouseX, MouseY
loop
{
if IsClicked = U
{
MouseMove, %MouseX%, %MouseY%
break
}
else
{
Func1()
}
}
}
}
}
}
As you can see I assigned it a value on line 18 please help me to understand why this is happening
Getfree
Posts: 231
Joined: 12 Oct 2014, 18:00

Re: This variable has not been assigned a value

19 Jul 2017, 22:32

Before you assign the value on line 18, you call function Func1() on line 3. That function uses the variable, so you need to assign a value to it before you call Func1().
Just move CheckVar := 0 above Func1() and it should work.
--kIWI--
Posts: 3
Joined: 18 May 2017, 20:36

Re: This variable has not been assigned a value

19 Jul 2017, 22:42

Thankyou, the error is gone however the script isnt working. I intended it to detect when the mouse it pressed, and when that happens to take the mouse pos. it would then loop, checking when the Lbutton is let go, moving it back to its original spot even if the mouse has been moved.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: DevWithCoffee, Rohwedder, Sarhad, Scr1pter and 131 guests