Jump to content

image search


Recommended Posts

Is it possible to compare the screen display to the image I save. The image contain the program - example TeamViewer with the OK button. The thing is; teamviewer doesn't appear at the same location (x, y position) so coordinates are useless. So to compare the image to screen and if find the OK button, to click on it.

If the tutorial is already out there, please link or point me to the right direction. Perhaps a quick example would be much helpful.

thanks,

Edit:

#include<ImageSearch.au3>

HotKeySet("[NUMPAD2]","start")
HotKeySet("[NUMPAD3]","quit")

$x1 = 0
$y1 = 0

while 1
    sleep(1)
WEnd

func start()
while 1
    $result=_ImageSearch("Button.png",1,$x1, $y1, 0)
        if $result=1 Then
            MouseClick("LEFT", $x1, $y1)
        EndIf
WEnd
EndFunc

Func quit()
    exit 0
EndFunc

For some reason it doesn't work even if the dll is within the include folder or with the image.

[edit]

T_T, comes to a search I found out that 64bit doesn't work.

Edited by asianqueen

Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.")
Link to comment
Share on other sites

I'm not sure I understand your problem. Why don't you use ControlClick to click the button?

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

if controlclick uses coordinates, I don't think it's possible because the apps doesn't appear at the same position x,y.

Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.")
Link to comment
Share on other sites

If it is a GUI button you want to click on then I suggest function Controlclick. It doesn't depend on screen positions but on the ControlID.

Or can you explain why you need to search for a picture and then click on it?

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

If you use WinMove to move the program window it will always be in the same position.

Link to comment
Share on other sites

If it is a GUI button you want to click on then I suggest function Controlclick. It doesn't depend on screen positions but on the ControlID.

Or can you explain why you need to search for a picture and then click on it?

This might be helpful if autoit can search for the exact look anywhere in windows that matches the image and click it. At least I would think it's easier since windows doesn't appear at the same position (x,y). Especially if I'm not the only one who's using it. Other people might have different resolution.

Belini

I'll take a look at your option. Seems like a good idea...

Edited by asianqueen

Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.")
Link to comment
Share on other sites

Water gave you the best solution for the example you gave.  Have you read the help file on ControlClick?  I use it all the time to automate software installations where I don't know where the window will be, or what size it will be.

The problem with using an image search to do it is that if a PC uses a different color scheme or fonts, the pixels may be different between what you are expecting and what the button looks like in reality.

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