Jump to content
Sign in to follow this  

Click on images/buttons by compare to stored image file

Recommended Posts


I have now been a rookie AutoIt programmer for about a month - and still learning.   :geek:

One aspect is to see what other can do; I was reading a little about the Sikuli project. It has some similarities with AutoIt, but in no way as mature and robust, but it has one feature I would like to replicate in my AutoIt scripts. It can find areas of the screen by compare stored image toward the desktop and find the similar area.  :pirate: 

Can I use a imagefile in AutoIt to do the same? 

In Sikuli it goes like this:

Find (screenarea1.png)
Click (screenarea1.png)

What happend is: Find an area in the screen that is exactly similar to "screenarea1.png". Mouse click the area.

Is there any way AutoIt can do this? :thumbsup: 





Automation and simplification is my game!

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  

  • Similar Content

    • By dynamitemedia
      i am trying to reuse code from another thread that was from 2011,  so i hope opening a new thread is Ok..  

      i have been working on this code trying to  make it work with a set of images i get from a xml file...  i haven't gotten that far yet i'm just setting the image count and later will get that  here is the code i have so far....
      #include <GUIConstantsEx.au3> #include <ButtonConstants.au3> #include <WinAPI.au3> #include <Skin.au3> #include <GDIPlus.au3> #include <Array.au3> #include <GuiButton.au3> #include <GuiListView.au3> #include "GUIScrollbars_Ex.au3" #include ".\Skins\Cosmo.au3" #include "_UskinLibrary.au3" _Uskin_LoadDLL() _USkin_Init(_Cosmo(True)) Global $X = 195, $Count = 0, $Width = 1250, $Height = 750 Global $sImagePath = @ScriptDir & "\Imgs\" ; Put your image paths in this array ;Global $aImage[8] = [$sImagePath & "League of Legends.bmp", $sImagePath & "Team Fortress 2.bmp", "Image_Path_3", "Image_Path_4", "Image_Path_5", "Image_Path_6", "Image_Path_7", "Image_Path_8"] Global $aImage[4000], $Button[4000] , $aLabel[4000], $aButton[4000], $aLabel[4000] Global $imgCount = 100 MainGui() Func MainGui() $MainGUI = GUICreate("", $Width, $Height) ; will create a dialog box that when displayed is centered] Opt("GUICoordMode", 20) For $i = 1 To $imgCount $X += 100 Next _GUIScrollbars_Generate($MainGUI, 0, $X) GUICtrlSetResizing(-1, $GUI_DOCKAUTO) ; Create labels For $i = 0 To $imgCount - 1 ; $Count += 1 For $j = 0 To 3 $iIndex = $j + ($i * 4) $aLabel[$iIndex] = GUICtrlCreateLabel("", 45 + (300 * $j), 25 + (300 * $i), 266, 266) GUICtrlSetBkColor($aLabel[$iIndex], 0xFFFFFF) GUICtrlSetState($aLabel[$iIndex], $GUI_DISABLE) Next Next ; Create buttons For $i = 0 To $imgCount - 1 ; $Count += 1 For $j = 0 To 3 $iIndex = $j + ($i * 4) $aButton[$iIndex] = GUICtrlCreateButton("Button " & ($iIndex + 1), 50 + (300 * $j), 30 + (300 * $i), 256, 256, $BS_BITMAP) GUICtrlSetImage($aButton[$iIndex], $aImage[$iIndex]) Next Next ; Set default button GUICtrlSetState($aButton[0], $GUI_FOCUS) GUICtrlSetBkColor($aLabel[0], 0x00FF00) $hActive = GUICtrlGetHandle($aButton[0]) ; Create dummy controls $cDummy_Up = GUICtrlCreateDummy() $cDummy_Dn = GUICtrlCreateDummy() GUISetState() ; Set the Up/Down keys as accelerators - they will only act like this when your GUI is active Local $aAccelKeys[2][2] = [["{UP}", $cDummy_Up], ["{DOWN}", $cDummy_Dn]] GUISetAccelerators($aAccelKeys) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $cDummy_Up, $cDummy_Dn _Vertical_TabStop() Case $aButton[$i] MsgBox($MB_SYSTEMMODAL, "Pressed", $aButton[$i]) EndSwitch ; Get focused control $hCurrFocus = _WinAPI_GetFocus() ; If it has changed If $hCurrFocus <> $hActive Then ; See if it is a button For $i = 0 To $imgCount If $hCurrFocus = GUICtrlGetHandle($aButton[$i]) Then ; Reset all the labels For $j = 0 To $imgCount GUICtrlSetBkColor($aLabel[$j], 0xFFFFFF) Next ; Highlight the correct label GUICtrlSetBkColor($aLabel[$i], 0x00FF00) ExitLoop EndIf Next $hActive = $hCurrFocus EndIf WEnd EndFunc ;==>Mainscript Func _Vertical_TabStop() ; Get active control $hActive = _WinAPI_GetFocus() For $i = 0 To 4 ; If it is a button If $hActive = GUICtrlGetHandle($aButton[$i]) Then ; Then determine index of the button above/below $iIndex = Mod($i + 4, $imgCount) ; And set focus GUICtrlSetState($aButton[$iIndex], $GUI_FOCUS) ; No point in looking further ExitLoop EndIf Next EndFunc  
      expand popup Now a couple issues i am having and maybe you can see the simple mistak9s)

      1.)  when button is clicked  it starts with saying button presses was the number 403 and stops at 504
      2.)  i cant go up and down ,  i can go down 3 and then it stops
      3.) the highlighting only goes so far and just stops which is actually 503
      4.) its showing more than 100 buttons
      5.) the scroll bar should stop at the last row and i cant seem to get that to work either

      I feel i am so close but so far 

      any help and explanation to what i am missing would be awesome

      i am basically taking images from a xml file and adding to the gui and need to use  up down and left and right arrows to  move to each one and highlight when i do.
  • Create New...