sigil Posted July 19, 2005 Posted July 19, 2005 I want to make an Excel window active. So I use this code: $excel="Microsoft Excel - 2005 Part D Seminars.xls" winactivate($excel) winwaitactive($excel) But when I run it, the Excel window doesn't come up, and the debugger tells me that it's hanging at winwaitactive($excel). This is such a basic thing to do, and I've made scripts before that use winActivate without any problems. What am I doing wrong?
/dev/null Posted July 19, 2005 Posted July 19, 2005 But when I run it, the Excel window doesn't come up, and the debugger tells me that it's hanging at winwaitactive($excel).Check the return code of winactivate() - see help file. I guess, that the window title is wrong. Use "AutoIT Window Info" tool to get the correct window title.CheersKurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *
sigil Posted July 19, 2005 Author Posted July 19, 2005 Check the return code of winactivate() - see help file. I guess, that the window title is wrong. Use "AutoIT Window Info" tool to get the correct window title.CheersKurt<{POST_SNAPBACK}>No, winactivate() returned 1.
Valuater Posted July 19, 2005 Posted July 19, 2005 did you "run" excel winactivate is for minimized,... etc windows 8)
sigil Posted July 19, 2005 Author Posted July 19, 2005 did you "run" excelwinactivate is for minimized,... etc windows8)<{POST_SNAPBACK}>Yes. The Excel window is open and the spreadsheet is running.
Valuater Posted July 19, 2005 Posted July 19, 2005 WinWaitActive ( "title", not win-handle.... $excel 8)
sigil Posted July 19, 2005 Author Posted July 19, 2005 WinWaitActive ( "title", not win-handle.... $excel8)<{POST_SNAPBACK}>$excel isn't the handle. It's the title, cut-and-pasted from AutoIt Window Info.
/dev/null Posted July 19, 2005 Posted July 19, 2005 No, winactivate() returned 1.<{POST_SNAPBACK}>I just tested your code on my system (W2k and Excel 2003). It works perfectly with the latest beta (.62).CheersKurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *
sigil Posted July 19, 2005 Author Posted July 19, 2005 $excel="Microsoft Excel - 2005 Part D Seminars.xls" ; this creates a handlewinactivate($excel) ; this is activating a handlewinwaitactive($excel) ; this is waiting for a handle$excel is a win-handle8)EDITmaybe you want thiswinwaitactive("Microsoft Excel - 2005 Part D Seminars.xls")8)<{POST_SNAPBACK}>That's not correct.$excel="Microsoft Excel - 2005 Part D Seminars.xls" does NOT create a handle. It makes a variable that is set to the text string to the right of the equal sign. Then, winwaitactive($excel) uses that variable to pass the text string to the winwaitactive() function.But on the chance that you're correct, I deleted $excel and put in the text string. It still didn't activate Excel, and winactivate() still returned 1.
herewasplato Posted July 19, 2005 Posted July 19, 2005 @Valuater, I think: $excel=WinGetHandle("Microsoft Excel - 2005 Part D Seminars.xls") ; this creates a handle @sigil, Okay, so you gave up on the use of a variable for now... Are these the only lines of code that you are working with?winactivate("Microsoft Excel - 2005 Part D Seminars.xls") winwaitactive("Microsoft Excel - 2005 Part D Seminars.xls")Do you have any options set via "AutoItSetOption"? Are you debugging this in a script by itself or as part of a larger script? Grasping at straws here...... [size="1"][font="Arial"].[u].[/u][/font][/size]
sigil Posted July 19, 2005 Author Posted July 19, 2005 Are these the only lines of code that you are working with?winactivate("Microsoft Excel - 2005 Part D Seminars.xls") winwaitactive("Microsoft Excel - 2005 Part D Seminars.xls")Do you have any options set via "AutoItSetOption"?Are you debugging this in a script by itself or as part of a larger script?Grasping at straws here......<{POST_SNAPBACK}>Those are the only two lines of code. I had AutoItSetOption("trayicondebug",1), but I took that out. Still nothing. I have no idea why a trivial function call is failing to perform.Again, the window title is cut-and-pasted from the Autoit Window Info tool.
herewasplato Posted July 20, 2005 Posted July 20, 2005 wow - okay Are you running it from SciTE or by double clicking on a *.au3 file (or from a complied script)? Try: AutoItSetOption ("WinTitleMatchMode", 2) WinActivate("Microsoft Excel") WinWaitActive("Microsoft Excel") More grasping at straws.... restart system... reinstall AutoIt... boot computer out of window.... [size="1"][font="Arial"].[u].[/u][/font][/size]
sigil Posted July 20, 2005 Author Posted July 20, 2005 wow - okayAre you running it from SciTE or by double clicking on a *.au3 file (or from a complied script)?Try:AutoItSetOption ("WinTitleMatchMode", 2)WinActivate("Microsoft Excel")WinWaitActive("Microsoft Excel")<{POST_SNAPBACK}>That works. Hm. It only works if I have no other Excel files open, even when I change the string to "Microsoft Excel - 2005", which would make it unique.Thank you for getting me this far.
herewasplato Posted July 20, 2005 Posted July 20, 2005 (edited) As you know --- "Microsoft Excel - 2005" --- should work! Want to keep chasing this rabbit? It is up to you... What editor are you making your scripts in, Notepad, SciTE or other. Could it be messing with spaces? <<< more straws If you are willing - run this script from the help file and see if your full title shows up in the list. (I know, it should be the same as the spy window - but something is not working as expected.) $var = WinList() For $i = 1 to $var[0][0] ; Only display visble windows that have a title If $var[$i][0] <> "" AND IsVisible($var[$i][1]) Then MsgBox(0, "Details", "Title=" & $var[$i][0] & @LF & "Handle=" & $var[$i][1]) EndIf Next Func IsVisible($handle) If BitAnd( WinGetState($handle), 2 ) Then Return 1 Else Return 0 EndIf EndFunc ...or maybe the hard way: AutoItSetOption("WinTitleMatchMode", 4) $handle = WinGetHandle("Microsoft Excel - 2005 Part D Seminars.xls") If @error Then MsgBox(4096, "Error", "Could not find the correct window") WinSetState ($handle, "", @SW_RESTORE) edit typo edit2 .... or maybe @SW_SHOWDEFAULT Edited July 20, 2005 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size]
jefhal Posted July 20, 2005 Posted July 20, 2005 How about?: $excel='"Microsoft Excel - 2005 Part D Seminars.xls"' The single quotes cause the double quotes to become part of the string... ...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
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