Pain Posted May 31, 2009 Share Posted May 31, 2009 (edited) Now this is just weird, some hour ago I made a script that worked as it should, but when I came back some hours later it didn't work so I tracked down the problem and found that WinGetTitle suddenly returned wrong value. No one have touched the computer or changed the code. This code now fails to me, even though it SHOULD return the title name, just like it did some hours ago. $title = WinGetTitle("[active]") If $title <> 0 Then; if the above function did not failed then MsgBox(0, "", $title) EndIf I've checked the output and it's certainly not a numeric zero (VarGetType shows it's a string....) and if I have the msgbox before the if statement I can see the title. $title = WinGetTitle("457689sd4fgh56sdvx4y99e8rd4s65gh4sd3fg1d3"); this window does NOT exist MsgBox(0, "", $title) That returns 0 and if I check the value with VarGetType it's Int32, so everything seems to work as it should here. I'm using version Autoit 3.3.0.0 and I've already tried to restart my computer. The same code worked perfectly some hours ago. I'm NOT using WinTitleMatchMode or any other Opt's, and even when I tried with WinTitleMatchMode it failed. I can't see anything wrong with WinGetTitle so I guess it's the If statement... Edited May 31, 2009 by Pain Link to comment Share on other sites More sharing options...
Developers Jos Posted May 31, 2009 Developers Share Posted May 31, 2009 try: $title = WinGetTitle("[active]") If $title Then MsgBox(0, "", $title) EndIf SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Pain Posted May 31, 2009 Author Share Posted May 31, 2009 (edited) Thanks Jos, that worked. But I'm still curious on why the script suddenly stopped to work even though I changed nothing. I better reinstall AutoIt before I continue with my project. Edited May 31, 2009 by Pain Link to comment Share on other sites More sharing options...
Developers Jos Posted May 31, 2009 Developers Share Posted May 31, 2009 (edited) You were doing a numeric comparison and a string equates 0 in that case. So cannot see it ever worked unless the window title contained just numerics.. Edited May 31, 2009 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Pain Posted May 31, 2009 Author Share Posted May 31, 2009 Strange, I must have changed it without even knowing it myself. :S Well anyways, thanks for the fast answer. 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