Jump to content

stop script when pixel(s) is not a certain colour


Recommended Posts

Hi I have recently made a script for a game i play, but i want to improve it but my skills at Auto it are lacking so ive came here for help.

what i want to do is make my script stop if the colour of certain pixels i set out, aren't a specific colour.

here is my current code:

Opt("WinWaitDelay",100)
Opt("WinTitleMatchMode",4)
Opt("WinDetectHiddenText",1)
Opt("MouseCoordMode",0)
WinWait("Monster&Me - MythOfOrient","")
If Not WinActive("Monster&Me - MythOfOrient","") Then WinActivate("Monster&Me - MythOfOrient","")
WinWaitActive("Monster&Me - MythOfOrient","")
Func _terminate ()
HotKeySet("{f10}", "_Terminate")
Exit
EndFunc



HotKeySet ( "{F10}" ,"_Terminate" )
while 1=1
MouseMove(317,489)
MouseDown("left")
MouseUp("left")
Sleep(7000)
MouseMove(318,488)
MouseDown("left")
MouseUp("left")
Sleep(7000)

Wend

for example i want it to do some thing like this:

If pixel (xxx,yyy) or pixel (xxx,yyy) is not colour (xxxxxxxx) then stop script

many thanks for any help

Link to comment
Share on other sites

HotKeySet( "{Esc}", "exit_now" )

While 1
    If ( PixelGetColor( x1, y1 ) = SOME_COLOR ) Or ( PixelGetColor( x2, y2 ) = SOME_COLOR ) Then
        exit_now()
    EndIf
    
    Sleep( 500 )
WEnd

Func exit_now()
     Exit
EndFunc

This will check the 2 pixel locations every 500mS and exit if either are found to be the color you are looking for.

Hope this helps.

_____________________________________________________"some people live for the rules, I live for exceptions"Wallpaper Changer - Easily Change Your Windows Wallpaper

Link to comment
Share on other sites

HotKeySet( "{Esc}", "exit_now" )

While 1
    If ( PixelGetColor( x1, y1 ) = SOME_COLOR ) Or ( PixelGetColor( x2, y2 ) = SOME_COLOR ) Then
        exit_now()
    EndIf
    
    Sleep( 500 )
WEnd

Func exit_now()
     Exit
EndFunc

This will check the 2 pixel locations every 500mS and exit if either are found to be the color you are looking for.

Hope this helps.

thanks, finally got my script working the way i liked , thanks so much :)

Link to comment
Share on other sites

if your going to re-use the same coordinates from pixelgetcolor x1, y1 and x2, y2 then through them into a variable :) it'll save you some type time later on lol...... ( im writing a small "bot" for a game too, and redundancy in coding becomes annoying lol )

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...