Jump to content

WinGetTitle


Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • Developers

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

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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...