gcue Posted March 8, 2011 Share Posted March 8, 2011 (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 March 8, 2011 by gcue Link to comment Share on other sites More sharing options...
martin Posted March 8, 2011 Share Posted March 8, 2011 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. Link to comment Share on other sites More sharing options...
gcue Posted March 8, 2011 Author Share Posted March 8, 2011 martin!!!!!!!!! hahah yep - still trying =) thx for the syntax correction hope you are well man. Link to comment Share on other sites More sharing options...
gcue Posted March 8, 2011 Author Share Posted March 8, 2011 actually that syntax wont work because $asset is in there ;-) Link to comment Share on other sites More sharing options...
ChrisL Posted March 8, 2011 Share Posted March 8, 2011 If your script is compiled you can also use Commandline arguments to run various functions that would normally stop script execution. expandcollapse popupIf $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 [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
gcue Posted March 8, 2011 Author Share Posted March 8, 2011 unfortunately, my script has several functions - most that cannot be run by command line bc they need user intervention. Link to comment Share on other sites More sharing options...
ChrisL Posted March 8, 2011 Share Posted March 8, 2011 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. [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
gcue Posted March 10, 2011 Author Share Posted March 10, 2011 (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 March 10, 2011 by gcue Link to comment Share on other sites More sharing options...
ChrisL Posted March 10, 2011 Share Posted March 10, 2011 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. [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
gcue Posted March 14, 2011 Author Share Posted March 14, 2011 (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 March 14, 2011 by gcue Link to comment Share on other sites More sharing options...
ChrisL Posted March 14, 2011 Share Posted March 14, 2011 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] = parameter2etc..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 [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
Carlo84 Posted March 14, 2011 Share Posted March 14, 2011 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 _SplashProgressImage | _Regionselector | _IsPressed360 | _UserAccountContol_SetLevel | _ListSubFolders 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