how can i continue this loop?

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
sltmnd
Posts: 3
Joined: 01 Jun 2023, 18:30

how can i continue this loop?

Post by sltmnd » 01 Jun 2023, 18:34

i'm looking for the colour 0x0000FD if the script finds this i want to sleep for 17-23 seconds. if it doesn't find this it can proceed to look for 0xA0FFFF and send click.

Code: Select all

loop 1  {

PixelSearch, Px, Py, 8, 31, 507, 360, 0x0000FD, 1, Fast ;
	if (ErrorLevel = 1) {

	sleep 17485, 23495


}

loop 2{




;Color ID: 0xA0FFFF 
	
	PixelSearch, Px, Py, 127, 60, 401, 95, 0xA0FFFF, 1, Fast
	if (ErrorLevel = 0) {
	Random, MouseSpeed, 14, 17
	Mousemove, 644, 132, %MouseSpeed%
	send {click}

Random ranSleep, 2000, 6000
	sleep %ranSleep%

User avatar
mikeyww
Posts: 26848
Joined: 09 Sep 2014, 18:38

Re: how can i continue this loop?

Post by mikeyww » 01 Jun 2023, 19:11

Welcome to this AutoHotkey forum!

You are posting in the v2 forum.

Did you write this script?

What should Sleep 17485, 23495 do? Where did you find this command syntax?

What are you attempting to do with your blocks & braces?

Do the loops end at any point? If so, on which line?

sltmnd
Posts: 3
Joined: 01 Jun 2023, 18:30

Re: how can i continue this loop?

Post by sltmnd » 01 Jun 2023, 19:41

mikeyww wrote:
01 Jun 2023, 19:11
Welcome to this AutoHotkey forum!

You are posting in the v2 forum.

Did you write this script?

What should Sleep 17485, 23495 do? Where did you find this command syntax?

What are you attempting to do with your blocks & braces?

Do the loops end at any point? If so, on which line?
I should be using
Random Sleep, 17485, 23495
sleep %Sleep%

can you explain why sleep 17485, 23495 is bad practice?

I need the first loop to detect the colour in the pixelsearch "0x0000FD", if it finds that it can sleep for the time period of 17-24 seconds. if it can't find it then it can proceed to the second loop that looks for

Code: Select all

PixelSearch, Px, Py, 127, 60, 401, 95, 0xA0FFFF, 1, Fast
and clicks at 644, 132.

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

Re: how can i continue this loop?

Post by boiler » 01 Jun 2023, 20:25

sltmnd wrote: can you explain why sleep 17485, 23495 is bad practice?
It’s bad practice to make up syntax that has no basis in the language and has no chance of working. Can you explain why you thought it should work other than because you wanted it to?

sltmnd
Posts: 3
Joined: 01 Jun 2023, 18:30

Re: how can i continue this loop?

Post by sltmnd » 01 Jun 2023, 22:20

boiler wrote:
01 Jun 2023, 20:25
sltmnd wrote: can you explain why sleep 17485, 23495 is bad practice?
It’s bad practice to make up syntax that has no basis in the language and has no chance of working. Can you explain why you thought it should work other than because you wanted it to?
id rather not go off topic, do you have any insight into how i can fix my problem?

User avatar
mikeyww
Posts: 26848
Joined: 09 Sep 2014, 18:38

Re: how can i continue this loop?

Post by mikeyww » 02 Jun 2023, 05:25

I'll offer my advice.

1. Decide if you would like to write a v1 or v2 script.
2. Post in the forum that matches the version you want: v1 or v2; gaming forum or not.
3. Refer to the AHK documentation that matches your version (v1 or v2).
4. Check the documentation carefully, so that you are following the provided syntax. AHK documentation includes examples for just about everything. As boiler noted, adding your own command parameters that are not part of the syntax will not lead to success.
5. Remove the loop commands during your testing, so that you can test a single iteration and get it working.
6. Read the documentation about blocks. A block has an opening brace and a closing brace. If you omit one of them, you create a bug in your script.
7. I suggest thinking about answering questions from the forum responders, because they are trying to help you achieve your goal. That is generally why they are responding to what you post. They are not responding simply to waste everyone's time.
8. When you post a broken script, describe what it actually does, and what it should do instead. Include an example.
9. Some people who come to the forum have brought ChatGPT output with them. This should be avoided.

As for me, I sign off when I encounter unresponsiveness-- as we are both getting nowhere-- but I wish you the best of luck, and others may provide more help for you here. You are on the right track, but I would follow your script line by line, because it doesn't match your description closely. Your description is not bad, so if you break it down into specific phrases, and then translate each phrase into a line of AHK code, you can probably fix this rather quickly.

Code: Select all

Sleep 50
Look for the colour 0x0000FD ; By default, colours in v1 are in Blue-Green-Red format
                             ; By default, coordinates are relative to the active window
If ErrorLevel {              ; If the colour is *not* found,
 Look for 0xA0FFFF           ;  then search again; and do what with the result?
 If __________               ; Under what condition?
  Click                      ;  click the left mouse button
} Else {                     ; Otherwise (if colour *is* found),
 ____________                ;  generate a random number,
 Sleep for 17-23 seconds     ;  and sleep;
}
; Do what next?

Post Reply

Return to “Ask for Help (v2)”