Page 1 of 1

loop not working

Posted: 25 Jun 2022, 02:10
by luigipizza431
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.]

Re: loop not working

Posted: 25 Jun 2022, 02:26
by vSky
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.]

Re: loop not working

Posted: 25 Jun 2022, 02:32
by luigipizza431
no, still doesn't work :(

Re: loop not working

Posted: 25 Jun 2022, 02:44
by vSky
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]

Re: loop not working

Posted: 25 Jun 2022, 03:05
by luigipizza431
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.

Re: loop not working

Posted: 25 Jun 2022, 03:10
by BoBo
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] ?

Re: loop not working

Posted: 25 Jun 2022, 03:26
by luigipizza431
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.

Re: loop not working

Posted: 25 Jun 2022, 03:35
by gregster
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.

Re: loop not working

Posted: 25 Jun 2022, 04:42
by boiler
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")