Start loop again with a key press

Get help with using AutoHotkey and its commands and hotkeys
Guest

Start loop again with a key press

10 Sep 2018, 00:53

Here's a script that checks if color is white. If it is, it start Loop anew. If it's not, it waits 10 seconds before starting Loop again. Please help me make it start Loop anew with a key press so it won't wait 10 seconds in the second situation.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Rindis
Posts: 202
Joined: 23 Dec 2013, 13:58
Location: Norway

Re: Start loop again with a key press

13 Sep 2018, 12:13

Could the banana fix it?
Not really sure what you want to happen....
(code untested)

Code: [Select all] [Expand] [Download] (Untitled.ahk)GeSHi © Codebox Plus

Guest

Re: Start loop again with a key press

14 Sep 2018, 23:09

This didn't work. Thank for trying to help.
I have a code that sends "hello" and searches for white color at (20, 285) every 160 milliseconds.
1. If it finds it, it keeps doing it.
2. If it doesn't find it, it waits 10 seconds and then keeps doing it.

I want to break this 10 seconds sleep at my will with a key so the code goes back to doing the loop.
Rohwedder
Posts: 1280
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Start loop again with a key press

15 Sep 2018, 01:21

Hallo,
to break this 10 seconds with key Escape
replace sleep 10000 by:and add at the end of your script:
Guest

Re: Start loop again with a key press

15 Sep 2018, 09:20

Rohwedder wrote:Hallo,
to break this 10 seconds with key Escape
replace sleep 10000 by:and add at the end of your script:

It didn't work.
Rindis
Posts: 202
Joined: 23 Dec 2013, 13:58
Location: Norway

Re: Start loop again with a key press

16 Sep 2018, 05:56

try this

F2 will start the program

F1 will break the waiting

Code: [Select all] [Expand] [Download] (Untitled.ahk)GeSHi © Codebox Plus

Guest

Re: Start loop again with a key press

17 Sep 2018, 01:02

Rindis wrote:try this

F2 will start the program

F1 will break the waiting

Code: [Select all] [Expand] [Download] (Untitled.ahk)GeSHi © Codebox Plus


This doesn't work. It doesn't even have 10 sec break in the code :(
Rindis
Posts: 202
Joined: 23 Dec 2013, 13:58
Location: Norway

Re: Start loop again with a key press

17 Sep 2018, 04:29

This part hast the 10 sec break:
while (banana=0)
{

sleep 100
if (A_Index = 100)
break
}

100 * 100 = 10 000 ....

how does it not work? what happens if you run it
Guest

Re: Start loop again with a key press

17 Sep 2018, 05:59

Rindis wrote:This part hast the 10 sec break:
while (banana=0)
{

sleep 100
if (A_Index = 100)
break
}

100 * 100 = 10 000 ....

how does it not work? what happens if you run it

If pixel's color is not white it doesn't do the loop every 10 seconds. It doesn't write hello every 10 seconds.
Guest

Re: Start loop again with a key press

17 Sep 2018, 10:13

I tried to insert the 'banana' part to the original code instead of Sleep 10000 but it didn't do anything:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Rindis
Posts: 202
Joined: 23 Dec 2013, 13:58
Location: Norway

Re: Start loop again with a key press

17 Sep 2018, 12:01

Sorry then I can't help you

Return to “Ask For Help”

Who is online

Users browsing this forum: No registered users and 79 guests