matching two error level with OR condition?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ravena1
Posts: 62
Joined: 06 Sep 2017, 15:13

matching two error level with OR condition?

17 Mar 2023, 22:45

help please
i want to double pixelsearch, and then press enter if it cannot find green or violet
i hope you can help me, thank you so much :)

Code: Select all

main()  {
Global
        pixelSearch, greenX, greenY, 30, 51, 759, 592, 0x21C642, 0, Fast RGB
        pixelSearch, violetX, violetY, 139, 182, 865, 643, 0x6B29A5, 0, Fast RGB
        green := ErrorLevel
        violet := ErrorLevel
	if green Or violet  { 
	msgbox, no green or violet colors found in the area, we should press enter
        sleep, 1500       
        send, enter
	return
  }
	
	else {
     sleep, 100
     return
	 }
    
}
Last edited by ravena1 on 18 Mar 2023, 01:54, edited 3 times in total.
ravena1
Posts: 62
Joined: 06 Sep 2017, 15:13

Re: matching two error level with OR condition?

18 Mar 2023, 01:45

i cant seem make it work, how about adding flags will it work?

Code: Select all

main()  {
Global
        pixelSearch, greenX, greenY, 30, 51, 759, 592, 0x21C642, 0, Fast RGB
        if (ErrorLevel = 0) 
        green := ok

        pixelSearch, violetX, violetY, 139, 182, 865, 643, 0x6B29A5, 0, Fast RGB
        if (ErrorLevel = 0) 
        violet := ok

	If( green = "ok") or (violet ="ok")  { 
	sleep, 10
	return
  }
	
	else {
       msgbox, no green or violet colors found in the area, we should press enter
       send {enter}
        sleep, 1500       
     return
	 }
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: matching two error level with OR condition?

18 Mar 2023, 03:31

if (green Or violet)

or in your 2nd post try setting variable to strings:
green := "ok"
violet := "ok"
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: matching two error level with OR condition?

18 Mar 2023, 04:24

store the errorlvl in a variable immediately after each call that sets errorlvl instead of storing errorlvl twice in two different variables AFTER the second errorlvl-setting-call has completed(because that would be storing the same errorlvl twice)
cat dog fox war
Posts: 38
Joined: 15 Mar 2023, 10:18

Re: matching two error level with OR condition?

18 Mar 2023, 06:41

Code: Select all

main() {
    Global
    pixelSearch, greenX, greenY, 30, 51, 759, 592, 0x21C642, 0, Fast RGB
    green := ErrorLevel
    pixelSearch, violetX, violetY, 139, 182, 865, 643, 0x6B29A5, 0, Fast RGB
    violet := ErrorLevel

    if (green or violet) {
        msgbox, % "no green or violet colors found in the area, we should press enter"
        sleep, 1500
        send, {enter}
        return
    } else {
        sleep, 100
        return
    }
}
I adjusted green := ErrorLevel before pixelSearch violetX, and send, enter -> send, {enter}

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 123 guests