NTKBO Posted January 23, 2006 Share Posted January 23, 2006 This is my first Auto it script. The situation is thus: I download files (NZB) and send them by association to a program (newsbin) which is associated with them. I have written a batch file to be run every time newsbin exits. There is currently no way to automate the process, untill I was pointed to AutoIt. The catch, I want to compile a script, then associate it with the NZB file. The script should send the NZB to newsbin, wait for it to exit, then run the batch file. But I may download up to 100 per session. So the script may be called MANY time to perform this, but only one instance of the wait should occur. The code I have tried does not seem to recognize when a NZB file has been sent to it. Dim $g_szVersion , $BatPath, $Val $g_szVersion = "NZB utility 1.0b1" If WinExists($g_szVersion) Then If $CmdLine[0]>1 Then $Val=Run(@COMSPEC " /c Start $CmdLine[1]") Exit Else Exit EndIf EndIf AutoItWinSetTitle($g_szVersion) If $CmdLine[0]>1 Then $Val=RunWait(@COMSPEC " /c Start $CmdLine[1]") $BatPath = IniRead ( "NZButil.ini", "Locations", "FoldersLoc" ) Run(@COMSPEC ' /c Start "$BatPath"') Else MsgBox(64, "Improper Start", "This program to be launched with a NZB file.") EndIf Exit Any pointers would be greatly appreciated. Link to comment Share on other sites More sharing options...
tonedeaf Posted January 23, 2006 Share Posted January 23, 2006 (edited) Try If CmdLine[0]>= 1 Then$CmdLine[0]is number of parameters $CmdLine[1] is param 1 (after the script name) $CmdLine[2] is param 2 etc Edited January 23, 2006 by tonedeaf Link to comment Share on other sites More sharing options...
NTKBO Posted January 23, 2006 Author Share Posted January 23, 2006 That was definately one of my problems. Another was that, if I change the file association to my Autoit script, the line: $Val=Run ( @COMSPEC " /c Start $CmdLine[1]" ) Should become two lines: $News = iniRead ( "NZButil.ini", "Locations", "Newsreader" , "c:\" ) $Val=RunWait ( @COMSPEC " /c Start $News $CmdLine[1]" ) To avoid a perpetual loop. I get an error on the syntax of that line. When SciTE error checks, it can't find the end parenthese. I've tried it both with and without a space before it. Do I have to pull $CmdLine[1] into a user variable first? >Running AU3Check G:\AutoIt Projects\Newsbin\NZButil.au3(18,52) : ERROR: syntax error $Val=Run ( @COMSPEC " /c Start $News $CmdLine[1]" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ Link to comment Share on other sites More sharing options...
MHz Posted January 23, 2006 Share Posted January 23, 2006 (edited) Just alittle adjustments that may suit. Should be no need for @comspec.Global $g_szVersion , $BatPath, $Val, $newsbin $newsbin = "<fullpath>"; FullPath to NewsBin $g_szVersion = "NZB utility 1.0b1" If WinExists($g_szVersion) Then If $CmdLine[0] = 1 Then $Val = Run($newsbin & ' "' $CmdLine[1] & '"') Exit EndIf AutoItWinSetTitle($g_szVersion) If $CmdLine[0] = 1 Then $Val = RunWait($newsbin & ' "' & $CmdLine[1] & '"') $BatPath = IniRead ( "NZButil.ini", "Locations", "FoldersLoc" ) Run($BatPath) Else MsgBox(64, "Improper Start", "This program to be launched with a NZB file.") EndIf ExitEdit: Your error above is the you are trying to insert a variable and an array into a string and missing the &'s Edited January 23, 2006 by MHz 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