why my variable fail to Repeat assignment? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
vbgfnd
Posts: 9
Joined: 07 Dec 2021, 23:03

why my variable fail to Repeat assignment?

Post by vbgfnd » 07 Dec 2021, 23:13

hello,friends i make a variable MyVar to Simulate a switch that

if i press alt+ctrl+shift+z MyVar will be "z" or "t"
and if i press k, it will Identify MyVar to decide how to do

but!first of all , press k it will trigger mouseMove, secondly, i press alt+ctrl+shift+z to kick down, and pressing k will send kkkkkkk
and then, if i press alt+ctrl+shift+z again, pressing k wont trigger mouseMove, and still send kkkk.

does anyone can help me ? i dont know what' s wrong :(

here is my code: :salute:

Code: Select all

global MyVar:="t" ;define a var

!+^z:: ;alt+ctrl+shift+z
if(MyVar=t){
	MyVar:="z"
	return
}else
{
	MyVar:="t"
	return
}

!+^x::MyVar:="x" ;alt+ctrl+shift+z

$k::
if(MyVar=t){
MouseMove, 0, -27, 0, R 
return
}
else{
	Send k
	return
}
[Mod edit: [code][/code] tags added.]

User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: why my variable fail to Repeat assignment?  Topic is solved

Post by Xtra » 08 Dec 2021, 00:20

vbgfnd wrote:
07 Dec 2021, 23:13
but!first of all , press k it will trigger mouseMove, secondly, i press alt+ctrl+shift+z to kick down, and pressing k will send kkkkkkk
and then, if i press alt+ctrl+shift+z again, pressing k wont trigger mouseMove, and still send kkkk.
Change:
if(MyVar=t)
To:
if (MyVar="t")
t is not a variable it is a string that needs to be quoted. To learn more read about: expressions here.

vbgfnd
Posts: 9
Joined: 07 Dec 2021, 23:03

Re: why my variable fail to Repeat assignment?

Post by vbgfnd » 08 Dec 2021, 00:46

Xtra wrote:
08 Dec 2021, 00:20
vbgfnd wrote:
07 Dec 2021, 23:13
but!first of all , press k it will trigger mouseMove, secondly, i press alt+ctrl+shift+z to kick down, and pressing k will send kkkkkkk
and then, if i press alt+ctrl+shift+z again, pressing k wont trigger mouseMove, and still send kkkk.
Change:
if(MyVar=t)
To:
if (MyVar="t")
t is not a variable it is a string that needs to be quoted. To learn more read about: expressions here.
thank you , Solved my problem,thank you verymuck :salute: :dance:

Post Reply

Return to “Ask for Help (v1)”