Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

If O is pressed, break loop



  • Please log in to reply
6 replies to this topic
AmejiKey
  • Members
  • 53 posts
  • Last active: Jun 06 2015 08:44 PM
  • Joined: 14 Nov 2014

So I read the help file on loops and breaks, but the only example is if a var > 25 or var <= 5, etc. 

What I want is a loop to break if a key is pressed. 

Take for example, my script:

 

Del::
Loop, 50
{
Send L
random,xx,750,1500
sleep %xx%
send K
Sleep 5000
}
 
Is there a way to say "If O is pressed, break"?
 
Thanks,
Ameji


SnowFlake_FlowSnake
  • Members
  • 845 posts
  • Last active: Jan 24 2016 05:24 PM
  • Joined: 08 Oct 2012

Hello again

 

This is probably not the best way of doing it but it works

 

Press o to stop the timer/loop or wait until it have looped 50 times

BreakKey = {o}

Del::
    SetTimer, Looper, 200
    Input,Key, I L1, %BreakKey%
    SetTimer, Looper, Off
return

Looper:
Counter++
IF (Counter = 50)
{
MsgBox Loop OFF
SetTimer, Looper, Off
}	
Send L
random,xx,750,1500
sleep %xx%
send K
Sleep 4800
return


  • Download link of my scripts on Autohotkey.com 2/10/2015 [DOWNLAND]
  • Contact Info:  https://github.com/floowsnaake //  FloowSnaake(A)gmail.com
  • IF you need Help send me a PM,Email or Post on Github

  • Quote by tank  Posted 29 September 2015 - 06:14 PM

  • "Eventually i will find a way to convert the DB back to PHPBB3. but i dont have the bandwidth right now. No one that has tried has had success. It is the Only way i can keep this open is if i could successfully convert it."

AmejiKey
  • Members
  • 53 posts
  • Last active: Jun 06 2015 08:44 PM
  • Joined: 14 Nov 2014

Alright, I'll test this out. Seems pretty nice though.



AmejiKey
  • Members
  • 53 posts
  • Last active: Jun 06 2015 08:44 PM
  • Joined: 14 Nov 2014

Yes, this works! Now, instead of making another thread, I just need one more request.

I want a MsgBox to pop up and tell me the xx number that it picks each time. I'm trying to test for a certain time, so if it lands on the time I want, I will press o to end the loop, and when I end the loop, it will say what xx was. I'm looking for a certain error message with this script, so I know when to press o. The reason I have a random generator for xx is so that I can find that time. 

 

Summary:

Press O to end loop when error message is found, MsgBox pops up telling what xx was.



SnowFlake_FlowSnake
  • Members
  • 845 posts
  • Last active: Jan 24 2016 05:24 PM
  • Joined: 08 Oct 2012

Do you mean like this?

 

MsgBox, Random Number: %xx% Loops made: %Counter%

OR

Tooltip, Random Number: %xx% Loops made: %Counter%

OR

fileappend, Random Number: %xx% Loops made: %Counter%`n,Debug.txt

BreakKey = {o}

X::
    SetTimer, Looper, 200
    Input,Key, I L1, %BreakKey%
    SetTimer, Looper, Off
return

Looper:
Counter++
random,xx,750,1500
MsgBox, Random Number: %xx% Loops made: %Counter%
IF (Counter = 50)
{
MsgBox Loop OFF
SetTimer, Looper, Off
}	
Send L
sleep %xx%
send K
Sleep 4800
return


  • Download link of my scripts on Autohotkey.com 2/10/2015 [DOWNLAND]
  • Contact Info:  https://github.com/floowsnaake //  FloowSnaake(A)gmail.com
  • IF you need Help send me a PM,Email or Post on Github

  • Quote by tank  Posted 29 September 2015 - 06:14 PM

  • "Eventually i will find a way to convert the DB back to PHPBB3. but i dont have the bandwidth right now. No one that has tried has had success. It is the Only way i can keep this open is if i could successfully convert it."

AmejiKey
  • Members
  • 53 posts
  • Last active: Jun 06 2015 08:44 PM
  • Joined: 14 Nov 2014

 

Do you mean like this?

 

MsgBox, Random Number: %xx% Loops made: %Counter%

OR

Tooltip, Random Number: %xx% Loops made: %Counter%

OR

fileappend, Random Number: %xx% Loops made: %Counter%`n,Debug.txt

BreakKey = {o}

X::
    SetTimer, Looper, 200
    Input,Key, I L1, %BreakKey%
    SetTimer, Looper, Off
return

Looper:
Counter++
random,xx,750,1500
MsgBox, Random Number: %xx% Loops made: %Counter%
IF (Counter = 50)
{
MsgBox Loop OFF
SetTimer, Looper, Off
}	
Send L
sleep %xx%
send K
Sleep 4800
return

Beautiful and working, but is there a way to make it log the numbers automatically?



Exaskryz
  • Members
  • 3249 posts
  • Last active: Nov 20 2015 05:30 AM
  • Joined: 23 Aug 2012
✓  Best Answer

You can probably make it log by using something like FileAppend or IniWrite, depending on how you'd like it done. I encourage you to read up on those. (Both so you can learn and because I don't have much time to keep procrastinating on my studies, hehe.)