Jump to content

Getting all Pixels in Outlined Area

Recommended Posts



im trying to click a random point inside an outlined Area like the one i Attached here. Im thinking of 2 Methods:


1. Scanning from left to right and top to bottom with pixelgetcolour so i get all the Outline coords. Then calculate all points in between min and max found coords for every horizontal line.

I think that would be very bad from performance perspektive (it needs to be done quick for my use, optimal in a few ms). 


2. Getting the first outline pixel found with pixelsearch and then moving the mouse down, left an right until colour found again. So basically "scanning" the area within the outline with my mouse and writing every coord where colour is not found to an array.

But i think that would be very slow too.


Some more Information: Outline Colour is not Black, the image attached is only for demonstrating purposes. The shape is not a star, its random everytime but always a closed line. And the outline is exactly 1px, not a fat line like in the image.


Am i thinking to complicated here? Or is there maybe a thing like "PixelSearchAll" so i get an array of coords?


Please excuse my bad English and thank you for your Help!




Link to post
Share on other sites

A heads up for you. Forgive me if I'm incorrect on this.

If you are asking for help in coding something for a game, that is a non-starter here. The way you are describing it strongly suggest that is your intent. Feel free to review the forum rules if you have any questions.

If your intent is to interact with a program that isn't game automation or interacting with a game server or an emulator that runs a game, would you be so kind in letting us know the name of the application please? Once I have that, I would be happy to assist you. I ask for it is highly likely someone else has solved your issue already and I can simply point you to it. Thanks in advance.

Link to post
Share on other sites

It is not for Game Automation or something like that. I have read the Rules.


I need this for phpmyadmin, i want to automatic import new sql files that i get from my Server every 30mins. To do this, i need to Navigate and click Different links and inputs. I dont want to use Webdriver so please dont suggest that and cant use imagesearch, because its on a virtual machine and imagesearch dont work. The Problem is, the things i need to click are outlined from css, but when i move the mouse to the first found Pixel it dont activate the link or button, because its not registering a hoverevent for the link. I need to move a little bit further into the outlined area to actually register a hover event and can click the link. But i cant do this with a random move from the found point, because the shapes are different and sometimes it would move over the endpoint where i can click. So i thought of getting all pixels in the outlined area and move my mouse to a point near the middle of the area. But to do this, i need all the pixels that are in the area to make my calculations and get a clickable point regardless of the shape.


I hope you understand what i mean, if not please ask and i will try to explain further, but i hope you get my point 

Link to post
Share on other sites

How about UIAutomation ?

In any case, PixelGetColor can be extremely slow (especially on Win10). I believe the best approach would be to capture the screen area of interest and transfer it to a 2D array.  Then you can search for specific patterns without requesting multiple reads of the screen.

Please show a real example of the screen you want to interact with.

Link to post
Share on other sites
Posted (edited)

#include <Array.au3>

Global $TopLeftX = 0
Global $TopLeftY = 0

Global $BotRightX = 10
Global $BotRightY = 10

Global $Array[$BotRightX - $TopLeftX + 1][$BotRightY - $TopLeftY + 1]

For $i = 0 To UBound($Array) - 1
    For $j = 0 To UBound($Array, 2) - 1
        $Array[$i][$j] = PixelGetColor($TopLeftX + $i, $TopLeftY + $j)


Thanks i just found this on the Forums, thats exactly what i needed. With this array i can Do my maths. You can close this.

P.S. Dont know why it writes in orange, maybe cause i pasted the Code and messed things up

Edited by Melba23
Fixed formatting
Link to post
Share on other sites
  • Moderators


When you post code in future please use Code tags - see here how to do it.  Then you get a scrolling box and syntax colouring as you can see above now I have added the tags. Thanks in advance for your cooperation.


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:


ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area


Link to post
Share on other sites

Seeing how you get this from a virtual server every 30 minutes - could you not make a script that runs on the virtual server that takes all the files and copies them to a specific folder?  That should be simple to do. Then all you need to do is import the contents of the folder to where you want. 

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