Sign in to follow this  
Followers 0
Pain

WinGetTitle

5 posts in this topic

#1 ·  Posted (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 by Pain

Share this post


Link to post
Share on other sites



#3 ·  Posted (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 by Pain

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Strange, I must have changed it without even knowing it myself. :S Well anyways, thanks for the fast answer.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0