Driveskull Posted March 11, 2014 Share Posted March 11, 2014 Hello . Gladly i get mine latest problem script solved ( and it was only simple image search adjustement nothing more ) But now i have a small problem , i have 3 scripts , i connected them using the code bellow after first closes opens second after second closes it opens third and after third closes it opens first . It works good , but the problem is , i cant close it normal way ( only task manager ) Is there a way to force this script loop to close when i dont need it ? OnAutoItExitRegister ( "FunctionName" ) Func FunctionName() Run("C:\Windows\System32\calc.exe") EndFunc Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 11, 2014 Moderators Share Posted March 11, 2014 Driveskull,What does that code snippet have to do with the problem you describe? 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...
iamtheky Posted March 11, 2014 Share Posted March 11, 2014 and thats not a loop... ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
DW1 Posted March 11, 2014 Share Posted March 11, 2014 Hello . Gladly i get mine latest problem script solved ( and it was only simple image search adjustement nothing more ) But now i have a small problem , i have 3 scripts , i connected them using the code bellow after first closes opens second after second closes it opens third and after third closes it opens first . It works good , but the problem is , i cant close it normal way ( only task manager ) Is there a way to force this script loop to close when i dont need it ? OnAutoItExitRegister ( "FunctionName" ) Func FunctionName() Run("C:\Windows\System32\calc.exe") EndFunc It would be easier to show you a better way if you posted your script, as calling the next application with OnAutoItExitRegister is not a great practice. But the quick way to modify your scripts would be to add a global variable to track when you do not want to call the next script and have the OnAutoItExitRegister function check it before calling the next application. In this example you will see that calc.exe will not get called if using the button at the bottom of the GUI. #include <GUIConstantsEx.au3> Global $bContinue = True OnAutoItExitRegister("FunctionName") Local $hGUI = GUICreate("Example") Local $iOK = GUICtrlCreateButton("Exit without running next app.", 200, 370, 200, 25) GUISetState(@SW_SHOW, $hGUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $iOK $bContinue = False Exit EndSwitch WEnd Func FunctionName() If $bContinue Then Run("C:\Windows\System32\calc.exe") EndFunc ;==>FunctionName AutoIt3 Online Help Link to comment Share on other sites More sharing options...
Driveskull Posted March 11, 2014 Author Share Posted March 11, 2014 Then maybe is there a way to write down 3 scripts into one ? They all using different img folders so i thought that OnAutoItExitRegister was the best option. expandcollapse popupFIRST #include <ImageSearch.au3> #include <File.au3> #include <Misc.au3> AdlibRegister("_MyExitFunc", 35000) ;40sec HotKeySet("{ESC}", "Terminate") ;Creates an Array with all the file names in your image folder Dim $imageList = _FileListToArray(@WorkingDir & "\Images") ;Change name to folder that holds your images. ;--------- Dim $imageName Dim $imageX Dim $imageY Dim $imageCount $image = $imageList[1] ;First image in file dont use 1 number ;This will search the entire screen for the image If _ImageSearchArea(@WorkingDir & "\Images\copper.png" , 1, 0, 150, @DesktopWidth, @DesktopHeight, $imageX, $imageY, 0) = 1 Then ;------------------ MouseMove($imageX, $imageY, 0) Sleep(100) ;A small amount of time for the mouse to move to the image MouseClick("Left") Sleep(25) MouseClick("Left") Sleep(25) EndIf $imageCount = 2 While $imageCount <= (UBound($imageList) - 1) ;will continue until there are no more images in the array $image = $imageList[$imageCount] While _ImageSearchArea(@WorkingDir & "\Images\" & $image, 1, 0, 150, @DesktopWidth, @DesktopHeight, $imageX, $imageY, 0) = 1 MouseMove($imageX, $imageY, 0) Sleep(200) MouseClick("Left") Sleep(211) WEnd $imageCount = $imageCount + 1 WEnd Func Terminate() Exit EndFunc Func _MyExitFunc() Exit ;Terminate the script EndFunc second expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.10.2 Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- #include <ImageSearch.au3> #include <File.au3> #include <Misc.au3> Sleep(100) AdlibRegister("Terminate", 37000) ;40sec HotKeySet("{ESC}", "Terminate") Dim $imageList = _FileListToArray(@WorkingDir & "\Images1") Dim $imageList2 = _FileListToArray(@WorkingDir & "\Images2") ;--------- ;Dim $imageName Dim $imageX Dim $imageY ;Dim $imageCount Sleep(100) While 1 For $i = 1 To UBound($imageList) - 1 $image = _ImageSearchArea(@WorkingDir & "\Images1\" & $imageList[$i], 1, 0, 150, @DesktopWidth, @DesktopHeight, $imageX, $imageY, 0) = 1 If $image = 1 Then MouseMove($imageX, $imageY, 0) Sleep(1000) MouseClick("Right") Sleep(300) ;$image1 = 0 EndIf Next For $i = 1 To UBound($imageList2) - 1 $image = _ImageSearchArea(@WorkingDir & "\Images2\" & $imageList2[$i], 1, 0, 150, @DesktopWidth, @DesktopHeight, $imageX, $imageY, 0) = 1 If $image = 1 Then MouseMove($imageX, $imageY, 0) Sleep(200) MouseClick("Left") Sleep(50) ;$image1 = 0 EndIf Next WEnd Func Terminate() Exit EndFunc ;==>Terminate third expandcollapse popup#include <ImageSearch.au3> #include <File.au3> #include <Misc.au3> AdlibRegister("_MyExitFunc", 10000) ;40sec HotKeySet("{ESC}", "Terminate") ;Creates an Array with all the file names in your image folder Dim $imageList = _FileListToArray(@WorkingDir & "\Images") ;Change name to folder that holds your images. ;--------- Dim $imageName Dim $imageX Dim $imageY Dim $imageCount $image = $imageList[1] ;First image in file dont use 1 number ;This will search the entire screen for the image If _ImageSearchArea(@WorkingDir & "\Images\1.png" , 1, 0, 150, @DesktopWidth, @DesktopHeight, $imageX, $imageY, 0) = 1 Then ;------------------ MouseMove($imageX, $imageY, 0) Sleep(100) ;A small amount of time for the mouse to move to the image MouseClick("Left") Sleep(25) MouseClick("Left") Sleep(25) EndIf Func Terminate() Exit EndFunc Func _MyExitFunc() Exit ;Terminate the script EndFunc Link to comment Share on other sites More sharing options...
DW1 Posted March 11, 2014 Share Posted March 11, 2014 I see no reason that you cannot simply combine them to one script. Try it, and troubleshoot if it doesn't work at first. AutoIt3 Online Help Link to comment Share on other sites More sharing options...
Driveskull Posted March 11, 2014 Author Share Posted March 11, 2014 But how , they are in the different folder and using different image folders, they have alot of similiar code . By combining you mean simple copy paste ? that wont work for sure Link to comment Share on other sites More sharing options...
iamtheky Posted March 11, 2014 Share Posted March 11, 2014 Why, it doesnt have to be @WorkingDir? You could roll a function of that first part passing the folder, no? ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) 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