Jump to content
Sign in to follow this  
Hadl

Long command line for Run and RunWait

Recommended Posts

Hadl

Hello,

I did develop a script which is doing some screenshots and then merging them together to one big picture.

The merging task is done with ImageMagick Montage.

With a 10 x 10 Matrix of pictures the command consists of:

- the command line interpreter with patch (C:\WINDOWS\system32\cmd.exe)

- the montage.exe command

- 100 filenames with absolute path

- some options

- the filename for the result.

When the Autoit script is running the command it seems like the command is truncated after 4048 characters. The path I supply to the RunWait command is then appended to those 4048 characters.

I could reproduce the error with a more simply script which is running the echo command.

$cmd= @ComSpec & " /k echo "
for $x=0 to 9
    for $y=0 to 9
        $cmd&= """D:\Screenshots\ExampleScreenshot_10x10_tile_0" & $x & "_0" & $y & ".bmp"" "
    Next
Next
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $cmd = ' & $cmd & @crlf) ;### Debug Console
RunWait($cmd,"C:\")

The $cmd variable is correctly

@@ Debug(7) : $cmd = C:\WINDOWS\system32\cmd.exe /k echo "D:\Screenshots\ExampleScreenshot_10x10_tile_00_00.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_00_01.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_00_02.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_00_03.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_00_04.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_00_05.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_00_06.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_00_07.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_00_08.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_00_09.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_01_00.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_01_01.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_01_02.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_01_03.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_01_04.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_01_05.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_01_06.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_01_07.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_01_08.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_01_09.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_02_00.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_02_01.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_02_02.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_02_03.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_02_04.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_02_05.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_02_06.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_02_07.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_02_08.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_02_09.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_03_00.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_03_01.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_03_02.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_03_03.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_03_04.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_03_05.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_03_06.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_03_07.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_03_08.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_03_09.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_04_00.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_04_01.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_04_02.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_04_03.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_04_04.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_04_05.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_04_06.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_04_07.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_04_08.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_04_09.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_05_00.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_05_01.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_05_02.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_05_03.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_05_04.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_05_05.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_05_06.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_05_07.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_05_08.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_05_09.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_06_00.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_06_01.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_06_02.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_06_03.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_06_04.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_06_05.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_06_06.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_06_07.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_06_08.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_06_09.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_07_00.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_07_01.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_07_02.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_07_03.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_07_04.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_07_05.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_07_06.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_07_07.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_07_08.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_07_09.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_08_00.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_08_01.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_08_02.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_08_03.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_08_04.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_08_05.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_08_06.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_08_07.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_08_08.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_08_09.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_09_00.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_09_01.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_09_02.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_09_03.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_09_04.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_09_05.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_09_06.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_09_07.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_09_08.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_09_09.bmp"

Whereas the command window shows the following:

"D:\Screenshots\ExampleScreenshot_10x10_tile_00_00.bmp" "D:\Screenshots\ExampleS
creenshot_10x10_tile_00_01.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_00_
02.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_00_03.bmp" "D:\Screenshots\
ExampleScreenshot_10x10_tile_00_04.bmp" "D:\Screenshots\ExampleScreenshot_10x10_
tile_00_05.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_00_06.bmp" "D:\Scre
enshots\ExampleScreenshot_10x10_tile_00_07.bmp" "D:\Screenshots\ExampleScreensho
t_10x10_tile_00_08.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_00_09.bmp"
"D:\Screenshots\ExampleScreenshot_10x10_tile_01_00.bmp" "D:\Screenshots\ExampleS
creenshot_10x10_tile_01_01.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_01_
02.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_01_03.bmp" "D:\Screenshots\
ExampleScreenshot_10x10_tile_01_04.bmp" "D:\Screenshots\ExampleScreenshot_10x10_
tile_01_05.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_01_06.bmp" "D:\Scre
enshots\ExampleScreenshot_10x10_tile_01_07.bmp" "D:\Screenshots\ExampleScreensho
t_10x10_tile_01_08.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_01_09.bmp"
"D:\Screenshots\ExampleScreenshot_10x10_tile_02_00.bmp" "D:\Screenshots\ExampleS
creenshot_10x10_tile_02_01.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_02_
02.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_02_03.bmp" "D:\Screenshots\
ExampleScreenshot_10x10_tile_02_04.bmp" "D:\Screenshots\ExampleScreenshot_10x10_
tile_02_05.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_02_06.bmp" "D:\Scre
enshots\ExampleScreenshot_10x10_tile_02_07.bmp" "D:\Screenshots\ExampleScreensho
t_10x10_tile_02_08.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_02_09.bmp"
"D:\Screenshots\ExampleScreenshot_10x10_tile_03_00.bmp" "D:\Screenshots\ExampleS
creenshot_10x10_tile_03_01.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_03_
02.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_03_03.bmp" "D:\Screenshots\
ExampleScreenshot_10x10_tile_03_04.bmp" "D:\Screenshots\ExampleScreenshot_10x10_
tile_03_05.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_03_06.bmp" "D:\Scre
enshots\ExampleScreenshot_10x10_tile_03_07.bmp" "D:\Screenshots\ExampleScreensho
t_10x10_tile_03_08.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_03_09.bmp"
"D:\Screenshots\ExampleScreenshot_10x10_tile_04_00.bmp" "D:\Screenshots\ExampleS
creenshot_10x10_tile_04_01.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_04_
02.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_04_03.bmp" "D:\Screenshots\
ExampleScreenshot_10x10_tile_04_04.bmp" "D:\Screenshots\ExampleScreenshot_10x10_
tile_04_05.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_04_06.bmp" "D:\Scre
enshots\ExampleScreenshot_10x10_tile_04_07.bmp" "D:\Screenshots\ExampleScreensho
t_10x10_tile_04_08.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_04_09.bmp"
"D:\Screenshots\ExampleScreenshot_10x10_tile_05_00.bmp" "D:\Screenshots\ExampleS
creenshot_10x10_tile_05_01.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_05_
02.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_05_03.bmp" "D:\Screenshots\
ExampleScreenshot_10x10_tile_05_04.bmp" "D:\Screenshots\ExampleScreenshot_10x10_
tile_05_05.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_05_06.bmp" "D:\Scre
enshots\ExampleScreenshot_10x10_tile_05_07.bmp" "D:\Screenshots\ExampleScreensho
t_10x10_tile_05_08.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_05_09.bmp"
"D:\Screenshots\ExampleScreenshot_10x10_tile_06_00.bmp" "D:\Screenshots\ExampleS
creenshot_10x10_tile_06_01.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_06_
02.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_06_03.bmp" "D:\Screenshots\
ExampleScreenshot_10x10_tile_06_04.bmp" "D:\Screenshots\ExampleScreenshot_10x10_
tile_06_05.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_06_06.bmp" "D:\Scre
enshots\ExampleScreenshot_10x10_tile_06_07.bmp" "D:\Screenshots\ExampleScreensho
t_10x10_tile_06_08.bmp" "D:\Screenshots\ExampleScreenshot_10x10_tile_06_09.bmp"
"D:\Screenshots\ExampleScreenshot_10x10_tile_07_00.bmp" "D:\Screenshots\ExampleS
creenshot_10x10_tile_07_01.bmp" "D:\Screenshots\ExampleScreeC:\

C:\>

The result shows that the filename for file 07_02 is truncated and the workingdir parameter is added. The workingdir is correctly.

When directly copying the correct command to a dos box everything works fine. So there should be no general windows limitation of command length.

Is this a limitation of the Run and RunWait command, did I do something wrong or is there a bug in those commands?

I did run the scripts with Autoit 3.2.0.1 and 3.2.10.0 and using SciTE 1.75

Share this post


Link to post
Share on other sites
ChrisL

Probably related to the limits of Autoit

Maximum length of a single script line: 4,095

Maximum string length: 2,147,483,647 characters

Also

only 63 parameters can be return by $CmdLine[...], but $CmdLineRaw will always returns the entire command line.

Perhaps you should change your command line method, send ImageDir=D:\Screenshots Images=ExampleScreenshot_10x10_tile_00_01.bmp|ExampleScreenshot_10x10_tile_00_02.bmp|ExampleScreensh

ot_10x10_tile_00_03.bmp

Then you can use stringSplit and join the Image Directory back up with a list of image files

Edited by ChrisL

Share this post


Link to post
Share on other sites
Hadl

Thanks Hubertus, your workaround with writing the command string to a batch file did work.

Perhaps you should change your command line method, send ImageDir=D:\Screenshots Images=ExampleScreenshot_10x10_tile_00_01.bmp|ExampleScreenshot_10x10_tile_00_02.bmp|ExampleScreensh

ot_10x10_tile_00_03.bmp

Then you can use stringSplit and join the Image Directory back up with a list of image files

When using the stringSplit, the result would be an Array with the filenames. To pass this Filenames to a command line I would have to joins them to one text string for RunWait, so I'm back at the same problem If I understand your solution correctly.

Share this post


Link to post
Share on other sites
JSunn

You may be better utilizing a combination of single and double-quotes for your string, like this:

$cmd &= '"D:\Screenshots\ExampleScreenshot_10x10_tile_0' & $x & '_0' & $y & '.bmp" '

instead of this:

$cmd&= """D:\Screenshots\ExampleScreenshot_10x10_tile_0" & $x & "_0" & $y & ".bmp"" "

Makes building the string with double-quotes a little less confusing as the double quotes are what you actually want to appear in the output string, and the singles are invisible.

-

John

Share this post


Link to post
Share on other sites
PsaltyDS

You may be better utilizing a combination of single and double-quotes for your string, like this:

$cmd &= '"D:\Screenshots\ExampleScreenshot_10x10_tile_0' & $x & '_0' & $y & '.bmp" '

instead of this:

$cmd&= """D:\Screenshots\ExampleScreenshot_10x10_tile_0" & $x & "_0" & $y & ".bmp"" "

Makes building the string with double-quotes a little less confusing as the double quotes are what you actually want to appear in the output string, and the singles are invisible.

Even better:
$cmd &= '"' & FileGetShortName('D:\Screenshots\ExampleScreenshot_10x10_tile_0' & $x & '_0' & $y & '.bmp') & '" '

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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  

×