Page 1 of 1
Trouble Coding
Posted: 15 Jun 2018, 15:58
by minimeng
So i was trying to make a hot key for a game that i play and i got it to work but when i do my win+p again it doesn't turn off and i was wondering if any of you guys new what the problem was. Here is the code that im working with.
#MaxThreadsPerHotKey 2
SetKeyDelay, 1500
#p::
toggle := !toggle
loop
{
if toggle
send t{up}{enter}
else
break
}
return
Re: Trouble Coding Topic is solved
Posted: 15 Jun 2018, 16:08
by MaxAstro
That's actually fairly clever. I think the problem is that toggle is being interpreted as a string in the if statement, so it's always true. Try changing if toggle to if (toggle).
Re: Trouble Coding
Posted: 15 Jun 2018, 16:14
by minimeng
It didnt work thx for thrying tho
Re: Trouble Coding
Posted: 15 Jun 2018, 16:20
by jeeswg
Here's a possible solution:
Code: Select all
#If !toggle
q::
toggle := 1
Loop
{
if toggle
SoundBeep
else
break
Sleep, 500
}
return
#If
#If toggle
q::
toggle := 0
return
#If
Re: Trouble Coding
Posted: 15 Jun 2018, 16:28
by minimeng
It didnt work and it goes to fast because there is no delay! NVM it worked thanks so much