Jump to content
Mingre

/AutoIt3ExecuteLine question

Recommended Posts

Mingre

Hello,

I just learned about /AutoIt3ExecuteLine to run lines outside your codes.

The usual code passed to run a series of lines is to put all those lines in a single declaration line such as Local (see above post).

But I learned through guinness' _InetGet() function (see below) another way of running series of lines:

Local $cmd = 'Exit (msgBox(0, "First", "") ? 1 : 0) * (msgBox(0, "Second", "") ? 1 : 0)'

 

My questions are:

(1) Am I right in saying that the code below basically translates to the next one?

Local $cmd = 'Exit (msgBox(0, "First", "") ? 1 : 0) * (msgBox(0, "Second", "") ? 1 : 0)'
Local $sCommand = '"' & StringReplace($cmd, '"', "'") & '"'
ConsoleWrite($sCommand & @CRLF)
Run(@AutoItExe & ' /AutoIt3ExecuteLine ' & $sCommand)
msgBox(0, "First", "")
msgBox(0, "Second", "")
Exit

(2) Can someone explain how "( ? 1: 0)" works? I see them as ways to run two separate lines but using them as such won't allow me to run this:

Local $sCommand = _
        'Exit (Local $x = msgBox(0, "First", "")) * (msgBox(0, "Second", "") ? 1 : 0)'
$sCommand = '"' & StringReplace($sCommand, '"', "'") & '"'
ConsoleWrite($sCommand & @CRLF)
Run(@AutoItExe & ' /AutoIt3ExecuteLine ' & $sCommand)

 

Thanks so much!

Edited by Mingre
Rephrased my questions.

Share this post


Link to post
Share on other sites
Mingre

To put all my questions simply: is there a pattern/syntax to convert an autoit program (say a couple of lines) to a single line that can be run with "/AutoIt3ExecuteLine"?

Share this post


Link to post
Share on other sites
jguinch

/AutoIt3ExecuteLine  is made to execute one line of code. If your code cannot be written in one line, you have to put you code in an external file and use /AutoIt3ExecuteScript instead.
In both cases, don't forget to put #pragma compile(AutoItExecuteAllowed, True) at the top of your main script

 

Share this post


Link to post
Share on other sites
Mingre

@jguinch

Thanks for the rep!

But what confuses me is how this code (which translates to three lines in a typical autoit code) works.

Local $sCommand = '(msgBox(0, "First", "") * (Tooltip("Boo!") * (msgBox(0, "Second", "")'
$sCommand = '"' & StringReplace($sCommand, '"', "'") & '"'
ConsoleWrite($sCommand & @CRLF)
Run(@AutoItExe &  ' /AutoIt3ExecuteLine ' & $sCommand)

Do you know a list of notations, e.g., "( ) * ( )", that I can use? Thanks!

Share this post


Link to post
Share on other sites
Mingre

What I'm trying to achieve is to run a UDF (e.g., _ArrayDisplay) with this, but that requires #include...

Local $sCommand = 'Local $x[2] = [0, 1], $dummy = _ArrayDisplay($x)'


$sCommand = '"' & StringReplace($sCommand, '"', "'") & '"'
ConsoleWrite($sCommand & @CRLF)
Run(@AutoItExe &  ' /AutoIt3ExecuteLine ' & $sCommand)

 

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

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.