Jump to content

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

endless loop with hotkey pause



  • Please log in to reply
11 replies to this topic
badchicken
  • Members
  • 77 posts
  • Last active: Apr 16 2016 10:58 AM
  • Joined: 22 Nov 2012

Hi, is it possible to have an endless loop on this script listed below? and with a hotkey if pressed it breakes out of loop, and if pressed again it re activates it.

q::
Click, right,
Mousemove, 0, 110, 5, Rel
click, left
Mousemove,   350, -473, 5, rel
click, left
Mousemove,  -350,  363, 5, rel
return

many thanks in advance to the wonderful comnunity here.



Menixator
  • Members
  • 744 posts
  • Last active: Sep 01 2015 02:54 PM
  • Joined: 10 Jul 2013

Like this? (Use Winkey+P to pause)


q::
Loop
{
	Click, right,
	Mousemove, 0, 110, 5, Rel
	click, left
	Mousemove,   350, -473, 5, rel
	click, left
	Mousemove,  -350,  363, 5, rel
}
return

#p::Pause,Toggle


badchicken
  • Members
  • 77 posts
  • Last active: Apr 16 2016 10:58 AM
  • Joined: 22 Nov 2012

ye pretty much yes the loop seems to be working but there was no pause i tryed everything it dident pause so i ended up shutting down my comp actualy to get back to here lmao was funny, anyway mate it seems to be working fine bro but can we fix the pause tho ? or maybe a reset breaking out of loop better just in case something wrong happend i wanna start over



Menixator
  • Members
  • 744 posts
  • Last active: Sep 01 2015 02:54 PM
  • Joined: 10 Jul 2013

ye pretty much yes the loop seems to be working but there was no pause i tryed everything it dident pause so i ended up shutting down my comp actualy to get back to here lmao was funny, anyway mate it seems to be working fine bro but can we fix the pause tho ? or maybe a reset breaking out of loop better just in case something wrong happend i wanna start over


Did you press Winkey+P?

badchicken
  • Members
  • 77 posts
  • Last active: Apr 16 2016 10:58 AM
  • Joined: 22 Nov 2012

ahh man its working! so sorry dident know its with the win key how dumb of me, well kind of new to autohotkey, but mate i wanted something which would break the whole loop and start over again :( cuz my script is so long i really really appriciate the script u gave me but can it reset with any given hotkey? and start over.



Menixator
  • Members
  • 744 posts
  • Last active: Sep 01 2015 02:54 PM
  • Joined: 10 Jul 2013
✓  Best Answer

In that case: (Esc to break the loop, Q to start it again)

b=0
q::
Loop
{
	If (b = 1)
	{
		b=0
		break
	}
	Click, right,
	Mousemove, 0, 110, 5, Rel
	click, left
	Mousemove,   350, -473, 5, rel
	click, left
	Mousemove,  -350,  363, 5, rel
}
return

Esc::b := !b


badchicken
  • Members
  • 77 posts
  • Last active: Apr 16 2016 10:58 AM
  • Joined: 22 Nov 2012

ur a genius my friend thank you so much thank you veruy very much!!!!! it works :) aewsome ! :))))))))))))))))))))))))))))))))) lol :D



Menixator
  • Members
  • 744 posts
  • Last active: Sep 01 2015 02:54 PM
  • Joined: 10 Jul 2013

ur a genius my friend thank you so much thank you veruy very much!!!!! it works happy.png aewsome ! happy.png)))))))))))))))))))))))))))))))) lol grin.png


You are welcome.cool.png And, i noticed that this is used to close all the windows open.

If you want to do that more effectively, you should use the Winclose command. <http://docs.ahk.com/Winclose>



Menixator
  • Members
  • 744 posts
  • Last active: Sep 01 2015 02:54 PM
  • Joined: 10 Jul 2013

Ok! Good luck!



caldwelljt
  • Members
  • 3 posts
  • Last active: Jul 19 2013 11:58 PM
  • Joined: 15 Jul 2013

I am trying to use this script, but I am not getting the behavior I expected.

 

The loop starts, but does not stop when hitting escape, it just keeps on looping



caldwelljt
  • Members
  • 3 posts
  • Last active: Jul 19 2013 11:58 PM
  • Joined: 15 Jul 2013

I am trying to use this script, but I am not getting the behavior I expected.

 

The loop starts, but does not stop when hitting escape, it just keeps on looping

 

 

ok, so that was a quick fix. I had 24 different keystrokes with 1 second between each one, but i wasn't  checking that b had changed except once bat the beginning of the loop. i tried it in notepad, hit esc, and had to walk away and noticed it had typed the rest of the letters then finished... easy fix :-)

 

is there a cleaner way to write it so that i don't have 

 
If (b = 1)
{
b=0
break
}
 
after each keypress? Here' what I'm trying to do:
 
Hit "1" six times, then "2" six times, then "1" six times, then "3" six times, and repeat it over and over until i hit esc (or some other key).
 
I could always look up for/next, but i'm really rusty on my scripting (i used to do it a lot, but i've been six for about 4 years (so sick i didn't used a computer for 3 1/2 years at all.)


Rijul Ahuja
  • Members
  • 763 posts
  • Last active: Nov 25 2013 10:16 AM
  • Joined: 14 Mar 2012

@caldwelljt

I could come up with a solution, if you are willing to use two scripts, and start a forum topic of your own seeking help.


Abandon the forum. The community has decided in a democratic vote to leave this website because of inactive and perverse administration.

Very few of the contributing members remain here.