Jump to content

About PixelSearch


squidol
 Share

Recommended Posts

I need help about pixel search. The problem with the script below is that PixelSearch does not continue on the coordinates where it has stopped.
When the first pixelsearch finds the 1st pixel, it should move the mouse over it and new pixels would appear just like hovering over menus. Then upon hover, there would be another PixelSearch to see if the second red pixel is found. If not found, then it should resume the first PixelSearch instead of starting from left to right again. 

For example we are doing a pixelsearch on two straight lines with coordinates  [x,y]  :

[0,0] [1,0] [2,0]

[1,0] [1,1] [1,2]

Pixelsearch finds the coordinate [1,0] matching our color. So it checks the pixel just below it which is [1,1] to see if it is color red. If not red then it should continue searching starting on coordinates [2,0] instead of going back to [0,0]

Local $bflag = False

Do
    ToolTip("finding..",0,0,"")
    Sleep(500)
    $var = PixelSearch(591, 169, 1365, 740, 0x464950,50) ; look for initial pixel
    If Not @error Then ;
        MouseMove($var[0],$var[1],0) ;move on the button to show new selections, new pixels
        sleep(1000)
        ;search for the red pixel on an area above the first pixel coords which was 
        ;generated when mouse cursor was hovered on the first pixel found.
        $redpixel = PixelSearch($var[0]-50,$var[1]-50,$var[0]+50,$var[1]+50,0xFF0048) 
        If Not @error Then ; Found the 2nd pixel
                ToolTip("found...",0,0,"")
            $bflag = True 
        EndIf
    EndIf
Until $bflag

I can pay 50USD through Paypal for a working solution. thanks :)  

Edited by squidol
Link to comment
Share on other sites

Can you please tell us which application you try to automate?
Pixelsearch is not very reliable as it depends on screen resolution and window position.
Most of the time there are better solutions to do what you want to do.
 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

5 minutes ago, water said:

Can you please tell us which application you try to automate?
Pixelsearch is not very reliable as it depends on screen resolution and window position.
Most of the time there are better solutions to do what you want to do.
 

Android application emulated on windows (no controls, classnames) where the UI does not have a definite location where it would popup. 

Link to comment
Share on other sites

If you search the forum you will find a few threads about Android emulator automation.
Maybe something like this is a good starting point:

 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

  • Developers

The Helpfile is your friend!

Quote

Remarks

The search direction varies as follows:
    Left-to-Right - left < right
    Right-to-Left - right < left
    Top-to-Bottom - top < bottom
    Bottom-to-Top - bottom < top
Changing the search direction can be a useful optimization if the color being searched for frequently appears in a specific quadrant of the search area since less searching is done if the search starts in the most common quadrant.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

2 minutes ago, Jos said:

The Helpfile is your friend!

Jos

i didnt really understand what that says until i realized the < > signs. 

so if i have the variables below:

Global $left = 0
Global $top = 0 
Global $right = 4
Global $bottom = 4

If $left is less than $right and $top is less than $bottom. Then the directions would be Left-to-Right and   Top-to-Bottom. Does the image below represent it?

9a047026be78d512d676e38b55fe6fe0.png

 

 


 

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

×
×
  • Create New...