loop not working

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
luigipizza431
Posts: 4
Joined: 25 Jun 2022, 01:43

loop not working

Post by luigipizza431 » 25 Jun 2022, 02:10

loop for my script isn't working, I have no idea why..

Code: Select all

^r::
send {w down}
loop
{

send {LButton down}
sleep 750
MouseMove, 0, -25, , R
sleep 750
MouseMove, 0, -45, , R
sleep 850
send {LButton up}
MouseMove, 0, 62, , R
sleep 500
send {Space down}
sleep 10
send {Space up}

if getkeystate ("h")
break
}
[Mod edit: [code][/code] tags added.]

User avatar
vSky
Posts: 80
Joined: 30 May 2022, 10:13

Re: loop not working

Post by vSky » 25 Jun 2022, 02:26

Can you try this

Code: Select all

^r::
send {w down}
loop
{
if getkeystate ("h")
break

send {LButton down}
sleep 750
MouseMove, 0, -25, , R
sleep 750
MouseMove, 0, -45, , R
sleep 850
send {LButton up}
MouseMove, 0, 62, , R
sleep 500
send {Space down}
sleep 10
send {Space up}
}
[Mod edit: [code][/code] tags added.]

luigipizza431
Posts: 4
Joined: 25 Jun 2022, 01:43

Re: loop not working

Post by luigipizza431 » 25 Jun 2022, 02:32

no, still doesn't work :(

User avatar
vSky
Posts: 80
Joined: 30 May 2022, 10:13

Re: loop not working

Post by vSky » 25 Jun 2022, 02:44

luigipizza431 wrote:
25 Jun 2022, 02:32
no, still doesn't work :(
It works.

Code: Select all

^r::
send {w down}
loop
{
if GetKeyState("H")  ; The key has been released, so break out of the loop.
 break

send {LButton down}
sleep 750
MouseMove, 0, -25, , R
sleep 750
MouseMove, 0, -45, , R
sleep 850
send {LButton up}
MouseMove, 0, 62, , R
sleep 500
send {Space down}
sleep 10
send {Space up}
}

home::ExitApp, [ ExitCode]

luigipizza431
Posts: 4
Joined: 25 Jun 2022, 01:43

Re: loop not working

Post by luigipizza431 » 25 Jun 2022, 03:05

vSky wrote:
25 Jun 2022, 02:44
luigipizza431 wrote:
25 Jun 2022, 02:32
no, still doesn't work :(
It works.

Code: Select all

^r::
send {w down}
loop
{
if GetKeyState("H")  ; The key has been released, so break out of the loop.
 break

send {LButton down}
sleep 750
MouseMove, 0, -25, , R
sleep 750
MouseMove, 0, -45, , R
sleep 850
send {LButton up}
MouseMove, 0, 62, , R
sleep 500
send {Space down}
sleep 10
send {Space up}
}

home::ExitApp, [ ExitCode]
dunno, still doesn't work for me.

BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: loop not working

Post by BoBo » 25 Jun 2022, 03:10

So you've pressed CTRL+r already, right? :think:
And bc there's no 'Return' set, you wanna use that Hotkey for a single time?
And you don't get an error message for this line home::ExitApp, [ ExitCode] ?

luigipizza431
Posts: 4
Joined: 25 Jun 2022, 01:43

Re: loop not working

Post by luigipizza431 » 25 Jun 2022, 03:26

BoBo wrote:
25 Jun 2022, 03:10
So you've pressed CTRL+r already, right? :think:
And bc there's no 'Return' set, you wanna use that Hotkey for a single time?
And you don't get an error message for this line home::ExitApp, [ ExitCode] ?
oh, no. I don't want to use the hotkey for a single time. i thought you could repeat the hotkey if you did a break, like an on and off switch.
also no, I don't get an error message for that line.

gregster
Posts: 8916
Joined: 30 Sep 2013, 06:48

Re: loop not working

Post by gregster » 25 Jun 2022, 03:35

BoBo wrote:
25 Jun 2022, 03:10
And you don't get an error message for this line home::ExitApp, [ ExitCode] ?
Well, it's an expression, returning a blank string. ;) So, its effect should be limited.
@luigipizza431: Not recommended, though. [ ]-brackets in the syntax descriptions signify optional parameters and are not to be used literally. Your usage could break things or lead to unexpected results when used with other statements.

User avatar
boiler
Posts: 16767
Joined: 21 Dec 2014, 02:44

Re: loop not working

Post by boiler » 25 Jun 2022, 04:42

It won’t work if you still have a space before the open parenthesis in your version of the script:

Code: Select all

if getkeystate ("h")

Post Reply

Return to “Ask for Help (v1)”