Sign in to follow this  
Followers 0
Queener

image search

8 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
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.")

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

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

Share this post


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

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
Sign in to follow this  
Followers 0