Jump to content
boat_58

Multiple PixelSearch Help

Recommended Posts

Is it possible to do multiple pixel searches at the same time? if so how do i go about in setting it up? For example:

3 scripts that i have to search for 3 different pixels with each doing the same thing if it finds the pixel and locks. It seems to work, but is there a more efficient way to set this up so that all 3 pixel searches are going the same time and which ever color is found first, is what is ran until the action is completed and it start searching again?

Quote

 

While (1)
    $cord = PixelSearch(1653, 575, 232, 99, 0x661212, 3)
    ;hunt for pixel
    If Not (@error) Then
        MouseClick("right", $cord[0], $cord[1], 1, 1)
        Sleep(2000)
        
        $highlighted = True

        While ($highlighted)
            $highlighted = PixelSearch(1065, 712, 1067, 714, 0x988327, 2)
            If Not (@error) Then
                MouseClick("left", 141, 1060)
                Sleep(1100) ; pause for 1 sec
            Else
                $highlighted = False
            EndIf
        WEnd
    Else
    
        $cord = PixelSearch(1653, 575, 232, 99, 0x661214, 3)
    ;hunt for pixel
    If Not (@error) Then
        MouseClick("right", $cord[0], $cord[1], 1, 1)
        Sleep(2000)
        
        $highlighted = True

        While ($highlighted)
            $highlighted = PixelSearch(1065, 712, 1067, 714, 0x988327, 2)
            If Not (@error) Then
                MouseClick("left", 141, 1060)
                Sleep(1100) ; pause for 1 sec
            Else
                $highlighted = False
            EndIf
        WEnd
    Else
    
        $cord = PixelSearch(1653, 575, 232, 99, 0x661213, 3)
    ;hunt for pixel
    If Not (@error) Then
        MouseClick("right", $cord[0], $cord[1], 1, 1)
        Sleep(2000)
        
        $highlighted = True

        While ($highlighted)
            $highlighted = PixelSearch(1065, 712, 1067, 714, 0x988327, 2)
            If Not (@error) Then
                MouseClick("left", 141, 1060)
                Sleep(1100) ; pause for 1 sec
            Else
                $highlighted = False
            EndIf
        WEnd
    Else
        ;turn 45 degrees
        MouseMove(850, 475)
        MouseDown("right")
        MouseMove(1088, 475)
        MouseUp("right")
    EndIf
    
WEnd

 

 

Share this post


Link to post
Share on other sites

your script isn't working at all..

if i understood right you are looking for something like

While 1
    For $i = 2 To 4
        Local $cord = PixelSearch(1653, 575, 232, 99, "0x66121" & $i, 3)
        If IsArray($cord) Then
            MouseClick("right", $cord[0], $cord[1], 1, 1)
            Sleep(2000)
            Do
                Local $highlighted = PixelSearch(1065, 712, 1067, 714, 0x988327, 2)
                Sleep(10)
            Until IsArray($highlighted)
            MouseClick("left", 141, 1060)
            Sleep(1100)
        EndIf
    Next
;   _turn()
    sleep(10)
WEnd

Func _turn()
    MouseMove(850, 475)
    MouseDown("right")
    MouseMove(1088, 475)
    MouseUp("right")
EndFunc   ;==>_turn

not tested!

actually im not sure what exactly you want but maybe this show you the way. :sorcerer: i just rescripted the given script but the "else" aren't that clear since you didn't close the if statements :P

 

EDIT: by the way i would set a hotkey to trigger it. :P I deactivated the constantly mousemove so far, because it would be annyoing :D 

Edited by Aelc

why do i get garbage when i buy garbage bags? <_<

Share this post


Link to post
Share on other sites

Working with Mouse* and Pixel* functions isn't very reliable as they depend on screen size and resolution, window position etc.
Can you please tell us which application you try to automate? Most of the time there are better ways to do what you want to do.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-12-15 - Version 1.6.3.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...