pawelliz Posted March 19, 2016 Share Posted March 19, 2016 (edited) Hello. I have a problem. I want to create a script that click on screen until it see image. I use image search, and create gui. Code that i have expandcollapse popup#include <GUIConstantsEx.au3> #include <ImageSearch2015.au3> $menu = "menu.PNG" $znszanse = "znszanse.PNG" $oreklame = "oreklame.PNG" $back = "back.PNG" $krec = "krec.PNG" $liczbaklikniec = 0 $x1 = 0 $y1 = 0 Example() Func Example() ; Create a GUI with various controls. Local $hGUI = GUICreate("Example", 300, 200) ; Create a button control. Local $500 = GUICtrlCreateButton("500", 120, 170, 85, 25) Local $idClose = GUICtrlCreateButton("Close", 210, 170, 85, 25) ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) Local $iPID = 0 ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idClose ExitLoop Case $500 ; Run Notepad with the window maximized. ConsoleWrite('klikna500') While 1 botzyc() Sleep(2000) WEnd EndSwitch WEnd ; Delete the previous GUI and all controls. GUIDelete($hGUI) ; Close the Notepad process using the PID returned by Run. If $iPID Then ProcessClose($iPID) EndFunc ;==>Example Func botzyc() $counter = 0 While $counter <= 5 menu() ZNszanse() Oreklame() powrot() WEnd EndFunc ;==>botzyc Func Cofnij() $result2 = _ImageSearch($back, 1, $x1, $y1, 0, 0) ConsoleWrite($result2) $result3 = _ImageSearch($krec, 1, $x1, $y1, 0, 0) ConsoleWrite($result3) Do Sleep(6000) MouseClick('primary', $x1, $y1, 1) Until $result3 = 1 EndFunc ;==>Cofnij Func menu() $result2 = _ImageSearch($menu, 1, $x1, $y1, 0, 0) ConsoleWrite($result2) If $result2 = 1 Then MouseClick('primary', $x1, $y1, 1) Else ConsoleWrite('nie widze menu') EndIf EndFunc ;==>menu Func ZNszanse() $result2 = _ImageSearch($znszanse, 1, $x1, $y1, 0, 0) ConsoleWrite($result2) If $result2 = 1 Then MouseClick('primary', $x1, $y1, 1) Else ConsoleWrite('nie widze szansy') EndIf EndFunc ;==>ZNszanse Func Oreklame() $result2 = _ImageSearch($oreklame, 1, $x1, $y1, 0, 0) ConsoleWrite($result2) If $result2 = 1 Then MouseClick('primary', $x1, $y1, 1) Sleep(1000) $liczbaklikniec = $liczbaklikniec + 1 Else ConsoleWrite('nie widze reklamy') EndIf EndFunc ;==>Oreklame Func powrot() $result2 = _ImageSearch($menu, 1, $x1, $y1, 0, 0) ConsoleWrite($result2) If $liczbaklikniec = 1 Then Do MouseClick('primary', 1269, 699, 1) Sleep(6000) Until $result2 = 1 MouseClick('primary', $x1, $y1, 1) $liczbaklikniec = $liczbaklikniec - 1 Else EndIf EndFunc ;==>powrot the problem is when shoud stop cliks it still does that. Please help Edited March 19, 2016 by Melba23 Added code tags Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 19, 2016 Moderators Share Posted March 19, 2016 pawelliz, Welcome to the AutoIt forums. When you post code please use Code tags - see here how to do it. Then you get a scrolling box and syntax colouring as you can see above now I have added the tags. But please pay attention to where you post - the "AutoIt Projects and Collaboration" section where you started this thread is not for general support questions. I have moved it for you, but would ask you to be more careful in future. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
JohnOne Posted March 19, 2016 Share Posted March 19, 2016 Problem looks to be your do until loops are waiting for a value to change, that never will. The search needs to be in the loop. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. 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