sciosalvi Posted January 17, 2014 Share Posted January 17, 2014 Hey guys, I'm trying to define a string to be a another script, so that it can be run independently of the first one and not interrupt the process. How can it be done? When I define a string variable, does it needs to be all in the same line? How can I convert a regular script to a onliner that Autoit would then reconstruct properly? Link to comment Share on other sites More sharing options...
sciosalvi Posted January 17, 2014 Author Share Posted January 17, 2014 For example, let's say I have this script here, the original without conversion to one line: ConsoleWrite('! = Red' & @CRLF) ConsoleWrite('> = Blue' & @CRLF) ConsoleWrite('- = Orange' & @CRLF ConsoleWrite('+ = Green' & @CRLF) How could I convert it to one line, like this for example, and either have it run like this or convert it back to the first version? ConsoleWrite('! = Red' & @CRLF) & @CRLF & ConsoleWrite('> = Blue' & @CRLF) & @CRLF & ConsoleWrite('- = Orange' & @CRLF) & @CRLF & ConsoleWrite('+ = Green' & @CRLF) Link to comment Share on other sites More sharing options...
water Posted January 17, 2014 Share Posted January 17, 2014 Why do you need to run it independently? ConsoleWrite is being done in a fraction of a second. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
JohnOne Posted January 17, 2014 Share Posted January 17, 2014 ConsoleWrite('! = Red' & @CRLF) + ConsoleWrite('> = Blue' & @CRLF) + ConsoleWrite('- = Orange' & @CRLF) + ConsoleWrite('+ = Green' & @CRLF) 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...
Unc3nZureD Posted January 17, 2014 Share Posted January 17, 2014 Wow, you can add more than one lines of codes with a + mark? Another good thing to know Link to comment Share on other sites More sharing options...
water Posted January 17, 2014 Share Posted January 17, 2014 You are simply adding the return values of the listed functions. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
jdelaney Posted January 17, 2014 Share Posted January 17, 2014 (edited) No matter what, one line or not, the operations will occur from left to right. They will never process at the same time (well...they can, but they would need to run as their own process, and those new processes would still be started from left to right). What's the real thing you are attempting to do? This sleeps for 8 seconds, not the max of the sleeps: $i = TimerInit() $i2 = Sleep(5000) + Sleep(2000) + Sleep(1000) ConsoleWrite(TimerDiff($i) & @CRLF) Edited January 17, 2014 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
sciosalvi Posted January 17, 2014 Author Share Posted January 17, 2014 Hey guys, thanks for the responses. I wasn't very clear. I don't need to run the commands in the same line, what I want to do is have multitasking in a way. Other functions need to run all the time, so I want to insert into my main script another script so that it can run in parallel, by being called externally. I know how to do that, what I don't know is how to create a string with the whole script. So, basically I need to adapt or compress a script with different lines into a text that can be converted by Autoit into a string that is the script. Or know a way to store multiline text inside one string. Link to comment Share on other sites More sharing options...
JohnOne Posted January 17, 2014 Share Posted January 17, 2014 I think FileInstall might be what you're looking for. 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...
jdelaney Posted January 17, 2014 Share Posted January 17, 2014 (edited) Like john stated, you can 'install' the au3 files into a compiled script, which durring run time copies out to a location, you can then execute the through a run command (not runwait). Helpfile = command line paramater: Form1: AutoIt3.exe [/ErrorStdOut] [/AutoIt3ExecuteScript] file [params ...] Execute an AutoIt3 Script File OR, if it is just one line of code: Run(@AutoItExe & ' /AutoIt3ExecuteLine "MsgBox(0, ''Hello World!'', ''Hi!'')"') Edited January 17, 2014 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
l3ill Posted January 17, 2014 Share Posted January 17, 2014 Seems to me what you are describing is essentially a UDF. My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example Link to comment Share on other sites More sharing options...
jdelaney Posted January 17, 2014 Share Posted January 17, 2014 (edited) If he want's to run functions in line (blocking), then that's fine. He want's to run in parallel, so would need to create a second process to execute. Like including a UDF, without actually including it . Edited January 17, 2014 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
Bert Posted January 17, 2014 Share Posted January 17, 2014 you can use an INI to share the values or the registry. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
sciosalvi Posted January 17, 2014 Author Share Posted January 17, 2014 Hey guys! I'm still not being understood, let me give you an example. I want to have one script that contains, in the same file, another script. Example (not saying it works, but this is something similar to what I need). The actual functions have no importance: #include <MsgBoxConstants.au3> $external_script = "ConsoleWrite('! = Red' & @CRLF) + ConsoleWrite('> = Blue' & @CRLF) + ConsoleWrite('- = Orange' & @CRLF) + ConsoleWrite('+ = Green' & @CRLF)" Run(@AutoItExe & "$external_script") While 1 Sleep(3000) MsgBox(0,"","Test") WEnd I could also use WriteFile to copy the string "$external_script" to disk if necessary. Link to comment Share on other sites More sharing options...
JohnOne Posted January 17, 2014 Share Posted January 17, 2014 Here is a very basic example. $external_script = "MsgBox(0,0,'external script')" FileWrite("ExternalScript.au3", $external_script) ShellExecute("ExternalScript.au3") 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...
Moderators JLogan3o13 Posted January 17, 2014 Moderators Share Posted January 17, 2014 (edited) I think you are not understanding what is being suggested. Write script 1, then use FileInstall to include it in script 2, as has been suggested: FileInstall("C:\Script2.au3", @TempDir & "\Script2.au3") Then call that script1 with the syntax jdelaney gave you in post 12. Whole lot easier than writing the thing on the fly. Edited January 17, 2014 by JLogan3o13 Gianni and sciosalvi 2 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! 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