Need help with until true.

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Pultz
Posts: 3
Joined: 18 Jan 2022, 01:52

Need help with until true.

Post by Pultz » 18 Jan 2022, 01:56

So, im currently trying to run 2 pixelsearchs, first one is the main, need the second to keep looping until true.. how would i do that?

Code: Select all

		PixelSearch, mX, mY, 300, 34, 520, 365, 0xFF3A00, 0, Fast
		If (ErrorLevel = 0)
		{
			MouseMove, mX, mY, 3
			Sleep, s1
			Click
			Sleep, s3
			Loop, until true
			{
				PixelSearch, fX, fY, 42, 50, 105, 71, 0x000000, 0, Fast
				If (ErrorLevel = 0)
				{
					
				}
				Else if (ErrorLevel = 1)
				{
					
				}
			}
		}
Any help highly appreciatet.. still new @ AHK.. used to use AutoIT but found AHK to be way better & easier to write in but for some reason i cant figure out how to make it loop this last pixelsearch part :morebeard:


Also how would one do this randomly

Code: Select all

Random, drop, "C:\Users\Hash-\Documents\AHK\AHK-Studio-master\Projects\Inv_empty.ahk", "C:\Users\Hash-\Documents\AHK\AHK-Studio-master\Projects\Inv_empty2.ahk"

RunWait, "drop"
Any way to make it randomly select one of the 2 files? :think:

User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: Need help with until true.

Post by Xtra » 18 Jan 2022, 04:12

Break loop when true:

Code: Select all

		PixelSearch, mX, mY, 300, 34, 520, 365, 0xFF3A00, 0, Fast
		If (ErrorLevel = 0)
		{
			MouseMove, mX, mY, 3
			Sleep, s1
			Click
			Sleep, s3
			Loop
			{
				PixelSearch, fX, fY, 42, 50, 105, 71, 0x000000, 0, Fast
				If (ErrorLevel = 0)
				{
					break    ; until true
				}
				Else if (ErrorLevel = 1)
				{
					
				}
			}
		}
Put file names in an array and choose which using the Random command.

Code: Select all

files := ["C:\Users\Hash-\Documents\AHK\AHK-Studio-master\Projects\Inv_empty.ahk","C:\Users\Hash-\Documents\AHK\AHK-Studio-master\Projects\Inv_empty2.ahk"]

Random, drop, 1, 2

RunWait, % files[drop]

Pultz
Posts: 3
Joined: 18 Jan 2022, 01:52

Re: Need help with until true.

Post by Pultz » 18 Jan 2022, 05:22

Xtra wrote:
18 Jan 2022, 04:12
Break loop when true:

Code: Select all

		PixelSearch, mX, mY, 300, 34, 520, 365, 0xFF3A00, 0, Fast
		If (ErrorLevel = 0)
		{
			MouseMove, mX, mY, 3
			Sleep, s1
			Click
			Sleep, s3
			Loop
			{
				PixelSearch, fX, fY, 42, 50, 105, 71, 0x000000, 0, Fast
				If (ErrorLevel = 0)
				{
					break    ; until true
				}
				Else if (ErrorLevel = 1)
				{
					
				}
			}
		}
Put file names in an array and choose which using the Random command.

Code: Select all

files := ["C:\Users\Hash-\Documents\AHK\AHK-Studio-master\Projects\Inv_empty.ahk","C:\Users\Hash-\Documents\AHK\AHK-Studio-master\Projects\Inv_empty2.ahk"]

Random, drop, 1, 2

RunWait, % files[drop]
Ty for the answer, I figured it out

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

Re: Need help with until true.

Post by boiler » 18 Jan 2022, 05:45

And to show how Until works:

Code: Select all

		PixelSearch, mX, mY, 300, 34, 520, 365, 0xFF3A00, 0, Fast
		If (ErrorLevel = 0)
		{
			MouseMove, mX, mY, 3
			Sleep, s1
			Click
			Sleep, s3
			Loop
			{
				PixelSearch, fX, fY, 42, 50, 105, 71, 0x000000, 0, Fast
				If (ErrorLevel = 0)
				{
					
				}
				Else if (ErrorLevel = 1)
				{
					
				}
			} Until ErrorLevel = 0
		}

Or, if any other statements that are executed after the ImageSearch and before the Until is reached happen to also potentially change the value of ErrorLevel, you can base it on a value that won’t change in between that also indicates that the search was successful:

Code: Select all

			} Until fX != ""

dpardinas
Posts: 11
Joined: 29 Sep 2020, 19:08

Re: Need help with until true.

Post by dpardinas » 26 Jan 2022, 15:08

Hello. I'm looking to be able to contact @Pultz, the poster of this issue. I am attempting to use AHK-Studio and I'm getting an error that it won't run on my computer. I have posted an issue on his page and on Github but haven't received a response yet.

If you can help, please contact me. Thank you.

Dianne

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

Re: Need help with until true.

Post by boiler » 26 Jan 2022, 16:24

dpardinas wrote: I have posted an issue on his page and on Github but haven't received a response yet.
It doesn't look like you have posted in the AHK Studio sub-forum yet, so you might try there.

Post Reply

Return to “Ask for Help (v1)”