1

I am trying to implement launching PuTTY with AutoIt.

I have a PuTTY configuration session, I named it 'testcom11'. It saves a PuTTY session with settings for com11, baudrate and so on.

I implemented in AutoIt a line as following:

Run ("putty -load testcom11")

It works fine. I was able to launch PuTTY with my session and PuTTY windows pops up and I was able to type an 'AT' command to the PuTTY window.

Now I want, instead of hard coding one session name, to pass a session name from the command line like this:

myAutoItprogram.exe testcom11

I put this line in AutoIt:

$cmp = $CmdLine[1]

I can see it passed correctly when I print (display it with, let's say, MsgBox) $cmp, it shows testcom11.

In the next line I have:

Run ("putty -load $cmp")

However, AutoIt launches PuTTY only with the window asking me to load a session. So clearly it didn't read the -load $cmp option.

As you can see I am novice to AutoIt, so maybe you can see if it is something with how it handles $cmp in Run Window or something else.

4

1 回答 1

2

你的语法不好。

AutoIt 可能类似于 PHP,但是...

$a = "x"
$b = "$ay"
if you print $b you will get this text $ay

正确的方法是

$b = $a & "y"

现在 $b 将打印xy

所以在你的情况下

Run("putty -load " & $cmp)

代替

Run ("putty -load $cmp")

还有关于 AutoIt 命令行。有$CmdLineRaw,它会得到整个命令行。为了将每个参数分开,您可以使用$CmdLine[n]n被每个参数索引替换)。

也许使用它更好$CmdLineRaw,因为您只传递一个参数,如果该参数中有空格,您可能会避免可能出现的问题。

于 2013-10-28T00:23:28.910 回答