Old_Man_Winter Posted May 10, 2006 Share Posted May 10, 2006 Hi, I'm new here, just discovered Autoit and it rocks! I also have my first problem: I want to activate a large number of successive windows: title = Figure 1, Figure 2, Figure 3 .... Figure N in a do/untill or for/next loop. eg: $n = 0 Do $n = $n + 1 WinActivate("Figure $n") Until $n = 200 Only this doesn't work of course. How do I put a variable in the WinActivate title ? Thanks alot Link to comment Share on other sites More sharing options...
MrBeatnik Posted May 10, 2006 Share Posted May 10, 2006 (edited) This should work (without testing):$n = 0 Do $n = $n + 1 WinActivate("Figure " & $n, "") Until $n = 200Forgot the , "" on the WinActivate Function. Edited May 10, 2006 by MrBeatnik Please correct me if I am wrong in any of my posts. I like learning from my mistakes too. Link to comment Share on other sites More sharing options...
Old_Man_Winter Posted May 10, 2006 Author Share Posted May 10, 2006 Nope, doesn't seem to work. The full title is "Figure No.1" etc. So I tried: $n = 0 Do $n = $n + 1 WinActivate("Figure No." & $n, "") sleep(1000) Until $n = 200 But nothing opens Link to comment Share on other sites More sharing options...
MHz Posted May 10, 2006 Share Posted May 10, 2006 (edited) Wait for the window, then use WinActivate. A For loop has a counter to suit use For $n = 1 To 200 WinWait("Figure No." & $n) WinActivate("Figure No." & $n) Sleep(1000) Next Edited May 10, 2006 by MHz Link to comment Share on other sites More sharing options...
Old_Man_Winter Posted May 10, 2006 Author Share Posted May 10, 2006 Sorry Tried it and it isn't working either Link to comment Share on other sites More sharing options...
seandisanti Posted May 10, 2006 Share Posted May 10, 2006 Sorry Tried it and it isn't working eitheryeah, the reason your first attempt wasn't working was because you have to concatenate the variable in as in the samples given. I bet, just based on the number of windows with successive titles like that, you're probably trying to activate child windows. try this... Opt("WinSearchChildren",1) $n = 1 While WinExists("Figure No." & $n) WinActivate("Figure No." & $n) $n = $n + 1 WEnd Link to comment Share on other sites More sharing options...
blueschism Posted May 12, 2006 Share Posted May 12, 2006 (edited) This should work (without testing): WinActivate("Figure " & $n, "") I'm having trouble activating a window using only a variable. Is there any reason that this shouldn't work? WinActivate($var) Thanks, mike Edited May 12, 2006 by blueschism Link to comment Share on other sites More sharing options...
MHz Posted May 12, 2006 Share Posted May 12, 2006 I'm having trouble activating a window using only a variable. Is there any reason that this shouldn't work? WinActivate($var) Thanks, mikeIt will work, if feed the correct string that the variable holds. Sorry, but the info that you supply is at best, guessing to solve. Link to comment Share on other sites More sharing options...
Bert Posted May 12, 2006 Share Posted May 12, 2006 You may want to do a winexists on each window, and use that information to build a array. From that information, you could do your winactivate. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
blueschism Posted May 12, 2006 Share Posted May 12, 2006 (edited) It will work, if feed the correct string that the variable holds. Sorry, but the info that you supply is at best, guessing to solve. I'm pulling parts quantities out of an AS400 system and updating one of 2 user selected excel spreadsheets. The AS400 window and both excel spreadsheets are open in the background when attempting this. It's not correctly grabbing the spreadsheet. Here are the sections that apply. expandcollapse popupOpt("WinTitleMatchMode", 2) ; which excel doc? $aLoop = 1 While $aLoop = 1 $xlsin = InputBox("Get stock amounts", "Enter:" & @CRLF & @CRLF & "1 for TOP 100" & @CRLF & "2 for Manual", "", "") If @error = 1 Then Exit Else If $xlsin = 1 Then $spreadsheet = "Top" ExitLoop ElseIf $xlsin = 2 Then $spreadsheet = "manual" ExitLoop Else MsgBox(4096, "Error", "You typed in the wrong thing - try again!") EndIf EndIf WEnd ; which line? $bLoop = 1 While $bLoop = 1 $ROW = InputBox("XLS Line to start on", "Enter Row number to start on", "2") If @error = 1 Then Exit ElseIf $ROW >= 2 Then $ROW = Int($ROW) ExitLoop EndIf WEnd ; start at excel field WinActivate($spreadsheet) Send("^{HOME}") Send("{DOWN " & $ROW & "}") Send("{UP}") The 2 excel docs are called: Top 100 Parts.xls manual spreadsheet.xls Any suggestions appreciated, mike Edited May 12, 2006 by blueschism 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