Queener Posted July 3, 2013 Share Posted July 3, 2013 (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 July 4, 2013 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 More sharing options...
water Posted July 4, 2013 Share Posted July 4, 2013 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 - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Queener Posted July 4, 2013 Author Share Posted July 4, 2013 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 More sharing options...
water Posted July 4, 2013 Share Posted July 4, 2013 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 - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
junkew Posted July 4, 2013 Share Posted July 4, 2013 this probably can help'?do=embed' frameborder='0' data-embedContent>> FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
Belini Posted July 4, 2013 Share Posted July 4, 2013 If you use WinMove to move the program window it will always be in the same position. My Codes: Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ Link to comment Share on other sites More sharing options...
Queener Posted July 8, 2013 Author Share Posted July 8, 2013 (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 July 8, 2013 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 More sharing options...
willichan Posted July 8, 2013 Share Posted July 8, 2013 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. My UDFs: Barcode Libraries, Automate creation of any type of project folder, File Locking with Cooperative Semaphores, Inline binary files, Continue script after reboot, WinWaitMulti, Name Aggregator, Enigma, CornedBeef Hash Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now