Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

PixelSearch & ControlSend?


  • Please log in to reply
1 reply to this topic
AntitheistPOV
  • Members
  • 56 posts
  • Last active: Nov 08 2017 10:12 AM
  • Joined: 24 Jun 2014
CoordMode, Pixel, Screen
CoordMode, Mouse, Screen
SetControlDelay -1

F1::
PixelSearch, Px, Py, 0, 0, 300, 300, 0xFFFFFF, 0, Fast
if ErrorLevel 0
ControlClick, %Px% %Py%, Notepad,, RIGHT, 2, NA

Hey,

 

Two questions.

 

1. Is this the correct format to ControlClick where the color "0xFFFFFF" was found? Doesn't seem to be working for me.

 

2. Is there any way to exclude a region within a PixelSearch area from the search? For example, if I want to search a square area but exclude the center of the square.

PX
|====================|
|                    |
|                    |
|        ___         |
|       |   |        |
|       | X |        |
|       |___|        |
|                    |
|                    |
|                    |
|====================|
                    PY


boiler
  • Members
  • 252 posts
  • Last active: Nov 07 2015 09:39 PM
  • Joined: 04 Jun 2014

There are a few issues with this:

 

1. It won't find your Notepad window the way you are specifying it unless you add SetTitleMatchMode, 2

2. Change your if statement to "if not ErrorLevel" or "if (ErrorLevel = 0)"

3. You left out the actual x and y characters that need to precede the values in the ControlClick statement.  It should be "ControlClick, x%Px% y%Py%, Notepad,, RIGHT, 2, NA"

4. That ControlClick will click relative to that window's coordinates, while you are searching relative to screen coordinates.  To click where you actually found the color, try Click, %Px%, %Py%, Right, 2

5. Not sure what you are trying to double-click using the right mouse button.  If you are trying to click in the white space of the Notepad window, it is finding the white in its icon in the title bar before it finds the white space in the editing part.  When I change the search coordinates to be within the white part of its window, it works in that it brings up the right-click context menu (even though only one click is needed for that, not two).  If you want to constrain it to that area, you should first determine the client area of the Notepad window and do your search within that area.

 

Regarding your question about excluding a region, the only way I would know how is to break it into 4 separate searches that cover the desired areas while leaving out the middle area.