Sign in to follow this  
Followers 0
gcue

AutoIt3ExecuteLine

12 posts in this topic

#1 ·  Posted (edited)

Hello.

I have used @AutoItExe and /AutoItExecuteLine for several autoit functions which have helped reduce what seems like a GUI freeze. Works great!

Any way I can use this functionality on all autoit functions within a script by default?

Here's an example of how I use it:

RunWait(@AutoItExe & ' /AutoIt3ExecuteLine "FileCopy(''' & @ScriptDir & '\bloomberg_update.exe'', ''\\' & $asset & '\c$\temp\'', 1 )"')

This is something I'm playing with but would there be a better way?

$command = FileCopy(@ScriptDir & '\bloomberg_update.exe', '\\' & $asset & '\c$\temp\', 1 )
OutsideGUI_Run($command)

Func OutsideGUI_Run($command)
    RunWait(@AutoItExe & ' /AutoIt3ExecuteLine "' & $command & '"') 
EndFunc
Edited by gcue

Share this post


Link to post
Share on other sites



Hello.

I have used @AutoItExe and /AutoItExecuteLine for several autoit functions which have helped reduce what seems like a GUI freeze. Works great!

Any way I can use this functionality on all autoit functions within a script by default?

Here's an example of how I use it:

RunWait(@AutoItExe & ' /AutoIt3ExecuteLine "FileCopy(''' & @ScriptDir & '\bloomberg_update.exe'', ''\\' & $asset & '\c$\temp\'', 1 )"')

This is something I'm playing with but would there be a better way?

$command = FileCopy(@ScriptDir & '\bloomberg_update.exe', '\\' & $asset & '\c$\temp\', 1 )
OutsideGUI_Run($command)

Func OutsideGUI_Run($command)
    RunWait(@AutoItExe & ' /AutoIt3ExecuteLine "' & $command & '"') 
EndFunc

Hi gcue, I see you're up to your usual tricks :)

Did you mean

$command = "FileCopy(@ScriptDir & '\bloomberg_update.exe', '\\' & $asset & '\c$\temp\',1)"
OutsideGUI_Run($command)

Func OutsideGUI_Run($command)
    RunWait(@AutoItExe & ' /AutoIt3ExecuteLine "' & $command & "')  
EndFunc

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

martin!!!!!!!!!

hahah yep - still trying =)

thx for the syntax correction

hope you are well man.

Share this post


Link to post
Share on other sites

actually that syntax wont work because $asset is in there ;-)

Share this post


Link to post
Share on other sites

If your script is compiled you can also use Commandline arguments to run various functions that would normally stop script execution.

If $CMDLINE[0] > 0 then

    Switch $CMDLINE[1]

        Case 1
            _CommandLine1()
        Case 2
            _CommandLine2()
        Case 3
            _CommandLine3()

    EndSwitch
    Exit
EndIf


;Main script
_RunSelf(1)
Msgbox(0,"","I am the main script")





Func _CommandLine1()
    WinWait("","I am the main script")
    WinMove("","I am the main script",10,10)
    _RunSelf(2)
    Msgbox(0,"","Commandline1")
EndFunc

Func _CommandLine2()
    WinWait("","Commandline1")
    WinMove("","Commandline1",100,100)
    _RunSelf(3)
    Msgbox(0,"","Commandline2")
EndFunc

Func _CommandLine3()
    WinWait("","Commandline2")
    WinMove("","Commandline2",210,210)
    Msgbox(0,"","Commandline3 You get the idea by now")
EndFunc


Func _RunSelf($s_CMDLINE)

    If @compiled then
        Run('"' & @ScriptFullPath & '" ' & $s_CMDLINE, @scriptDir)
    Else
        Msgbox(0,"Error","This only works compiled!")
    EndIf

EndFunc

Share this post


Link to post
Share on other sites

unfortunately, my script has several functions - most that cannot be run by command line bc they need user intervention.

Share this post


Link to post
Share on other sites

I'm not sure what difference that makes at all.

Running via commandline arguments, AutoitExecuteLine or AutoitExecuteScript all 3 options run the function in a new process, therefore any communication with the main script needs to be via one of the many interscript communication UDF's available.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

not sure what you mean.

do you mean running two scripts? one thats the gui, and the other one that runs the commands via commandline?

Edited by gcue

Share this post


Link to post
Share on other sites

I showed you away to call functions from your main script that run without holding up your main script.

Autoit is not multi-threaded therefore any method used is going to involve some of the script running as a new process.

My commandline method is one way of storing the function inside the main script and calling itself with a commandline argument to launch a new process and call a function.

AutoitExecuteLine runs a single line of code as a new process

AutoitExecuteScript calls an external script as a new process

If you wish these functions to interact with your main script then you are going to need to look at interprocess / Script communication one of which can be located in my signature and there are many more if you search the forum.

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

using your interscript communication - works pretty well - thanks for sharing with us =)

i am passing a variable between 2 scripts that is seperated with a "|" which later i split into an array, which is something like

$array[0] = function

$array[1] = parameter1

$array[2] = parameter2

etc..

the only other thing that would make this even better is making one script the primary script, which starts the secondary script. and when you exit the primary script, it exits the secondary script...

not sure how to go about this...

Edited by gcue

Share this post


Link to post
Share on other sites

using your interscript communication - works pretty well - thanks for sharing with us =)

i am passing a variable between 2 scripts that is seperated with a "|" which later i split into an array, which is something like

$array[0] = function

$array[1] = parameter1

$array[2] = parameter2

etc..

the only other thing that would make this even better is making one script the primary script, which starts the secondary script. and when you exit the primary script, it exits the secondary script...

not sure how to go about this...

Call the second script with an a commandline argument with the PID of the main script, then adlibregister a function that checks for the main PID If NOT ProcessExists($PID) then Exit

Share this post


Link to post
Share on other sites

edit to use with AutoIt3ExecuteLine ?

or maybe im just missing the entire point.

#region Sample
    $i = _runScript('msgbox.au3', 0)
    MsgBox(64, 'Exitcode', 'RC: ' & $i)
    $i = _runScript('msgbox.au3', 1)
    MsgBox(64, 'Process ID', 'PID: ' & $i)
#endregion Sample

Func _runScript($au3, $wait = 0)
    Local $i
    If Not @Compiled Then Return SetError(1, 0, 0)
    Select
        Case $wait = 0 ;Returns when script exits, returns scripts exitcode
            $i = RunWait('"' & @ScriptFullPath & '" /AutoIt3ExecuteScript "' & $au3 & '"')
            If @error Then Return SetError(2)
            Return $i
        Case $wait = 1 ;Returns immidiatly returning scripts Process ID
            $i = Run('"' & @ScriptFullPath & '" /AutoIt3ExecuteScript "' & $au3 & '"')
            If @error Then Return SetError(2)
            Return $i
    EndSelect
EndFunc   ;==>_runScript

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  
Followers 0