Hold key release code help

Ask gaming related questions (AHK v1.1 and older)
ahkstarter
Posts: 1
Joined: 02 Jan 2018, 16:00

Hold key release code help

02 Jan 2018, 16:09

Hello guys, basically im trying to create a script that (holds down C key for 50 seconds) then (presses the number 6 key once) then (taps the left arrow key for 1/2 a second) then (holds down C key again for 50 seconds) then (presses the number 6 key once) but here (presses the right arrow key instead for 1/2 a second) and repeated in a loop in that format. And i could toggle it on/off by pressing F8 key.

I know it looks and sounds confusing but i basically do this in real life: C key held down 50 seconds and let go after 50 seconds, press number 6 key, lightly tap left key once. hold down C key again for 50 seconds and let go, press number 6 key, lightly tap right key once.

The reason i used a while loop to hold down the key is cause im unable to hold the key down using send and sleep commands. Appreciate all the help that i could get on this.

Also whenever i tried to run script, the error 'break has to be enclosed in a loop' keeps popping up, bamboozling me in the process

Code: Select all

if not A_IsAdmin
{
   Run *RunAs "%A_ScriptFullPath%"  ; Requires v1.0.92.01+
   ExitApp
}
; Run this script as admin, just to make sure....
SetTimer, Spam, 10
SetTimer, Spam, Off
F8::
Toggle := !Toggle
If Toggle = 1
   SetTimer, Spam, On
Else
   SetTimer, Spam, Off
Return
 
Spam:
while A_TimeSinceThisHotkey < 50001
        Send, c
	if A_TimeSinceThisHotkey = 50000
		break
return

Send, 6
Sleep 100
Send {Left Down}
Sleep 500
Send {Left Up}

while A_TimeSinceThisHotkey < 50001
        Send, c
	if A_TimeSinceThisHotkey = 50000
		break
return

Send 6
Sleep 100
Send {Right Down}
Sleep 500
Send {Right Up}


Return
cocobanana
Posts: 19
Joined: 31 Oct 2017, 05:43

Re: Hold key release code help

03 Jan 2018, 11:57

Code: Select all

if not A_IsAdmin
{
   Run *RunAs "%A_ScriptFullPath%"  ; Requires v1.0.92.01+
   ExitApp
}
; Run this script as admin, just to make sure....
SetTimer, Spam, 10
SetTimer, Spam, Off
F8::
Toggle := !Toggle
If Toggle = 1
   SetTimer, Spam, On
Else
   SetTimer, Spam, Off
Return
 
Spam:
while A_TimeSinceThisHotkey < 50001
{
	Send, c
	if A_TimeSinceThisHotkey = 50000
		break
}
return

Send, 6
Sleep 100
Send {Left Down}
Sleep 500
Send {Left Up}

while A_TimeSinceThisHotkey < 50001
 {
	Send, c
	if A_TimeSinceThisHotkey = 50000
		break
}
return

Send 6
Sleep 100
Send {Right Down}
Sleep 500
Send {Right Up}


Return

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: Google [Bot] and 70 guests