Jump to content
Sign in to follow this  
Driveskull

How to connect 3 scripts

Recommended Posts

Driveskull

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

Share this post


Link to post
Share on other sites
Melba23

Driveskull,

What does that code snippet have to do with the problem you describe? :huh:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
iamtheky

and thats not a loop...


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites
DW1

 

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

Share this post


Link to post
Share on other sites
Driveskull

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.

FIRST


#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

#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

#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

Share this post


Link to post
Share on other sites
DW1

I see no reason that you cannot simply combine them to one script.  Try it, and troubleshoot if it doesn't work at first.

Share this post


Link to post
Share on other sites
Driveskull

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 

Share this post


Link to post
Share on other sites
iamtheky

Why, it doesnt have to be @WorkingDir?

You could roll a function of that first part passing the folder, no?


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

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  

×