Trouble Coding Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
minimeng
Posts: 3
Joined: 15 Jun 2018, 15:54

Trouble Coding

15 Jun 2018, 15:58

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
MaxAstro
Posts: 557
Joined: 05 Oct 2016, 13:00

Re: Trouble Coding  Topic is solved

15 Jun 2018, 16:08

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).
minimeng
Posts: 3
Joined: 15 Jun 2018, 15:54

Re: Trouble Coding

15 Jun 2018, 16:14

It didnt work thx for thrying tho
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Trouble Coding

15 Jun 2018, 16:20

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
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
minimeng
Posts: 3
Joined: 15 Jun 2018, 15:54

Re: Trouble Coding

15 Jun 2018, 16:28

It didnt work and it goes to fast because there is no delay! NVM it worked thanks so much

Return to “Ask For Help”

Who is online

Users browsing this forum: ark, mikeyww and 34 guests