Jump to content

can you...?


Recommended Posts

Can you search for more than one color using pixel search within the same command line or a more effecient way instead of creating another command line again right after

$coord = PixelSearch(92, 453, 1214, 833, 0x2f0000, 0)

^ Can I insert more than one color?

Link to comment
Share on other sites

Darn.. hmm.. whats the best way to add more code into what I already have to search for another color and do the same thing as the first search? My brain seems tired right now and isn't figuring it out. :/

(edit)- I want it to search for both colors right after SendWithDelay(1100, '7456789') and if one or the other happen to match than the script does what its doing right now.

Func target()
    While 1
        
        $tofar = PixelGetColor (478,107)
        If $tofar = 0x2A0000 Then
            main()
        Else
            Sleep(1000)
        EndIf
        While 1
                $targetalive = PixelGetColor(74,176)
            IF $targetalive = 0x00E800 Then
                $targetalive = PixelGetColor(74,176)
                SendWithDelay(1100, '7456789')
                Sleep(4000)
                Local $coord = PixelSearch(92, 453, 1214, 833, 0x2f0000, 0)
                If Not @error And IsArray($coord) Then
                    MouseClick('left', $coord[0], $coord[1], 2, 1)
                    Sleep(1000)
                    MouseMove(265,506)
                    Sleep(1000)
                    MouseClick('left')
                    Sleep(1000)
                    Send('{ESC}')
                Else
                    ContinueLoop
                EndIf
                
            Else
                main()
            EndIf
        WEnd
        
    WEnd
EndFunc
Edited by adrian1386
Link to comment
Share on other sites

  • Moderators

This looks familiar... did I already answer this question for you?

Func target()
    While 1
        
        $tofar = PixelGetColor (478,107)
        $WAY_2_FAR = PixelGetColor(107, 478)
        If $tofar == 0x2A0000 Or $WAY_2_FAR == 0x2A0000 Then
            main()
        Else
            Sleep(1000)
        EndIf
        While 1
                $targetalive == PixelGetColor(74,176)
                $OTHER_TARGET_ALIVE == PixelGetColor(176,74)
            IF $targetalive == 0x00E800 Or $OTHER_TARGET_ALIVE == Then
                $targetalive = PixelGetColor(74,176); WHY IS THIS HERE? THERE IS NO ACTION TO BE TAKEN WITH IT?
                SendWithDelay(1100, '7456789')
                Sleep(4000)
                Local $coord = PixelSearch(92, 453, 1214, 833, 0x2f0000, 0)
                If Not @error And IsArray($coord) Then
                    MouseClick('left', $coord[0], $coord[1], 2, 1)
                    Sleep(1000)
                    MouseMove(265,506)
                    Sleep(1000)
                    MouseClick('left')
                    Sleep(1000)
                    Send('{ESC}')
                Else
                    ContinueLoop
                EndIf
                
            Else
                main()
            EndIf
        WEnd
        
    WEnd
EndFunc

Or you may want to do PixelSearch() If it is in a grouped area... if not, then take at what I typed and try and get some ideas with 'And' 'Or'.... Good Luck.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

This part..

Local $coord = PixelSearch(92, 453, 1214, 833, 0x2f0000, 0)
                If Not @error And IsArray($coord) Then
                    MouseClick('left', $coord[0], $coord[1], 2, 1)
                    Sleep(1000)
                    MouseMove(265,506)
                    Sleep(1000)
                    MouseClick('left')
                    Sleep(1000)
                    Send('{ESC}')
                Else
                    ContinueLoop
                EndIf

What I want to do is search for more than one color using pixelsearch, and the reason I asked if you could do it within the same line is because iam using a variable and that variable is being double clicked on depending on where its found on the screen using the PixelSearch. I want it to search for two colors and you said it cant be done within the same command line so iam just wondering whats the best way to do it? Sorry for being confusing, its 3:30 am lol and I'm tired but I wanna figure it out.

Thanks for quick replies tho, appreciate it.

Link to comment
Share on other sites

  • Moderators

I am tired... I totally started looking at this, but someone was asking for help on msn, and I got sidetracked.... how may different colors would there be?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Hmm I cant really test this right now inside the program but could this work smoke?

Func target()
    While 1
        
        $tofar = PixelGetColor (478,107)
        If $tofar = 0x2A0000 Then
            main()
        Else
            Sleep(1000)
        EndIf
        While 1
                $targetalive = PixelGetColor(74,176)
            IF $targetalive = 0x00E800 Then
                SendWithDelay(1100, '7456789')
                Sleep(4000)
                Local $coord = PixelSearch(92, 453, 1214, 833, 0x2f0000, 0)
                If Not @error And IsArray($coord) Then
                    MouseClick('left', $coord[0], $coord[1], 2, 1)
                    Sleep(1000)
                    MouseMove(265,506)
                    Sleep(1000)
                    MouseClick('left')
                    Sleep(1000)
                    Send('{ESC}')
                ElseIf
                    Local $coord2 = PixelSearch (92, 453, 1214, 833, 0x2f0022, 0)
                    If Not @error And IsArray($coord2) Then
                        MousClick('left', $coord2[0], $coord2[1], 2, 1)
                        Sleep(1000)
                        MouseMove(265, 506)
                        Sleep(1000)
                        MouseClick('left')
                        Sleep(1000)
                        Send('{ESC}')
                    EndIf
                Else
                    ContinueLoop
                EndIf
                
            Else
                main()
            EndIf
        WEnd
        
    WEnd
EndFunc
Edited by adrian1386
Link to comment
Share on other sites

  • Moderators

Does this work?

Func target()
$ColorString = '0x2A0000,0xFF0000,0x0000FF,0x00FF00'; this makes it easy to add multiple colors seperated by just a comma
Local $Color = StringSplit($ColorString, ','); this will make the array using the commas to seperate the colors
Local $coord = ''
    While 1
        $tofar = PixelGetColor (478,107)
        If $tofar == 0x2A0000 Then
            main()
        Else
            Sleep(1000)
        EndIf
        While 1
                $targetalive == PixelGetColor(74,176)
            IF $targetalive == 0x00E800 Then
                SendWithDelay(1100, '7456789')
                Sleep(4000)
                For $i = 1 To Ubound($Color) - 1; Number of Colors
                    $coord = PixelSearch(92, 453, 1214, 833, $Color[$i])
                    If Not @error And IsArray($coord) Then
                        MouseClick('left', $coord[0], $coord[1], 2, 1)
                        Sleep(2000)
                        MouseMove('left', 265, 506)
                        Sleep(1000)
                        Send('{ESC}')
                        If $i < Ubound($Color) - 1 Then ExitLoop
                    EndIf
                Next
            Else
                main()
            EndIf
        WEnd
        
    WEnd
EndFunc

Edit: Fixed a possible error that could be thrown.

Edit2: Instead of you getting confused with multiple $Colors[1]/[2] etc... I just put everything in a String, and Then a StringSplit() at the top for you.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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...