You might have your command line arguments wrong in AutoIt script. Better post that question in the AutoIt support forums.
I'm not too familiar with AutoIt script syntax, but from general programming,
If $CmdLine[0] < 2 Then
is more syntactically correct as
If $CmdLine < 2 Then
or similar to line above, but you may need to call an AutoIt function that returns the array count of command line arguments since $CmdLine itself is assumed to be an array, and you want the count, not the array, nor any particular index element of the array.
and you need to make sure for passing in the file name that you are referring to the correct array index. If $CmdLine[0] is the AutoIt script/executable name itself, then you are correct to use index 1, otherwise, you should use index 0 (as first command line parameter).
On Wednesday, June 20, 2012 4:42:40 AM UTC-7, scripting164 wrote:
Hii,
I am using selenium rc with java and trying to upload file for test using autoit. I am able to do the same, but I have to write a new script for each file to be uploaded for different scenarios.
Is there any way to pass file name as a parameter to the script, so that I can use only one script file.
I tried this but it gives Error: Array variable has incorrect number of subscript
Here is my script upload.au3:
#include<IE.au3>
If $CmdLine[0] < 2 Then
WinWait("Choose File to Upload")
$hChoose = WinGetHandle("Choose File to Upload")
ControlSetText($hChoose, "", "[CLASS:Edit; INSTANCE:1]",$CmdLine[1])
sleep(2000)
ControlClick($hChoose, "", "[CLASS:Button; INSTANCE:1]")
EndIf
And I am calling from java as below:
_selenium.click("id=movie-path");
String[] cmd = {path_to_file };
Process proc1 = Runtime.getRuntime().exec( "uploadfile3.exe",cmd);
Help needed...