anandnz Posted January 28, 2011 Posted January 28, 2011 I am trying to do some examples to achive a bigger task, one of which is my earlier postings .. In this small example, i am trying to pass variable as command for the application. ; Script Start - Add your code below here ; Attempt to create a unlimited parameters like ** in c, but not sure how. ; Pass this variable in a loop to command ; Create a log file text with append and save as system time ; Do nothing until a Dialog box comes up .. Local $cnt, $li[1] = ["Arnold", "Carol"] $cnt = 0 For $cnt=0 to 1 step 1 ConsoleWrite("notepad = " &$li[$cnt] &@CRLF ); Check if it prints the variable Run("Notepad.exe" &$li[$cnt]) ; It hangs here, cannot open notepad with variable name ; I want to see if i can pass a variable to the command .. WinWaitActive("Notepad") send("!&n") Next ;WinWaitActive(&$li[$cnt] - "Notepad") Any help in commands to use, example of log file text with append will be appreciated. Cheers
Varian Posted January 28, 2011 Posted January 28, 2011 (edited) Your $Li variable needed to have 2 elements, not 1...you also needed a space between noetpad.exe and your variable Local $Cnt, $Li[2] = ["Arnold", "Carol"] $Cnt = 0 ;no need to declare this like this...you should really use Local or Global if you want to be safe For $Cnt = 0 To 1 Step 1 ConsoleWrite("notepad = " & $Li[$Cnt] & @CRLF); Check if it prints the variable Run("Notepad.exe " & $Li[$Cnt]) ; It hangs here, cannot open notepad with variable name ; I want to see if i can pass a variable to the command .. WinWaitActive("Notepad") Send("!&n") Next Edited January 28, 2011 by Varian
anandnz Posted January 28, 2011 Author Posted January 28, 2011 Thanks Varian, You are right, $Li s actually 2 variables, i posted while i tried to check for single loop. Sorry about it. however the program hangs while trying to open notepad with command variable. I have inserted sace as suggested. Also please help me to create a log file with append and save as system time and date. ; Script Start - Add your code below here ; Attempt to create a unlimited parameters like ** in c, but not sure how. ; Pass this variable in a loop to command ; Create a log file text with append and save as system time ; Do nothing until a Dialog box comes up .. Local $li[2] = ["Arnold", "Carol"] Global $cnt = 0 For $cnt=0 to 1 step 1 ConsoleWrite("notepad = " &$li[$cnt] &@CRLF ); Check if it prints the variable Run("Notepad.exe" &$li[$cnt]) ; It hangs here, cannot open notepad with variable name ; I want to see if i can pass a variable to the command .. WinWaitActive("Notepad") send("!&n") Next ;WinWaitActive(&$li[$cnt] - "Notepad") Your $Li variable needed to have 2 elements, not 1...you also needed a space between noetpad.exe and your variable Local $Cnt, $Li[2] = ["Arnold", "Carol"] $Cnt = 0 ;no need to declare this like this...you should really use Local or Global if you want to be safe For $Cnt = 0 To 1 Step 1 ConsoleWrite("notepad = " & $Li[$Cnt] & @CRLF); Check if it prints the variable Run("Notepad.exe " & $Li[$Cnt]) ; It hangs here, cannot open notepad with variable name ; I want to see if i can pass a variable to the command .. WinWaitActive("Notepad") Send("!&n") Next
Varian Posted January 28, 2011 Posted January 28, 2011 #include <File.au3> ; Script Start - Add your code below here ; Attempt to create a unlimited parameters like ** in c, but not sure how. ; Pass this variable in a loop to command ; Create a log file text with append and save as system time ; Do nothing until a Dialog box comes up .. Local $Cnt, $Li[2] = ["Arnold", "Carol"] $Cnt = 0 For $Cnt = 0 To 1 Step 1 ConsoleWrite("notepad = " & $Li[$Cnt] & @CRLF); Check if it prints the variable Run("Notepad.exe " & $Li[$Cnt]) ; It hangs here, cannot open notepad with variable name ; I want to see if i can pass a variable to the command .. WinWaitActive("Notepad") Send("!&n") _FileWriteLog("C:\Logfile", "Your Text") ;add your log message...date & time will automatically prepend your text Next ;WinWaitActive(&$li[$cnt] - "Notepad")
anandnz Posted January 28, 2011 Author Posted January 28, 2011 Hi Varian, Thank you very much. It rocks .. It would have been hard for me to spot. Can i ask you two more questions so that i can implement my program. 1.I am calling a third party application which prompts dialog box, when it comes is not sure. Is there a way to wait for the dialog box named "Success" to appear. 2. Is there a way to implement indefinite length of string array Once again thanks a ton. cheers
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