Jump to content

Broken script using WinExists


Recommended Posts

okay so essentially there's a large program I'm making and in some part of it i launch some program and see if it exists with its given title. What i have given is not the whole script but is a modification of the parts of the script that prove my point. I set the title we are looking for to "LOL CATZ" and i clearly have nothing running with that as a substring, yet the program insists "Success!" Why?!

#include <WindowsConstants.au3>

AutoItSetOption("WinTitleMatchMode",2)

appStatReadyTest()

Func appStatReadyTest()
    
    $appTitle = "LOL CATZ"
    $appStatTestWin = GUICreate("Statistics Tester: " & $appTitle, 300,100,-1,-1,-1,$WS_EX_TOPMOST)
    
    GUICtrlCreateGroup("Status:",10,10,280,80)
    
    $label = GUICtrlCreateLabel("Opening Program...",20,35,260)
    $prog = GUICtrlCreateProgress(20,60,260,20)
    
    GUISetState(@SW_SHOW,$appStatTestWin)
    
    ;start the test
    Sleep(1000)
    ;ShellExecute($arr[$cRow][$cCol][$cTab][1])
    GUICtrlSetData($label,"Looking for " & Chr(34) & " *" & $appTitle & "* " & Chr(34) & " for 20 seconds...")
    
    $wExist = 0
    $i = 1
    While $i <= 20
        Sleep(1000)
        ToolTip(WinExists($appTitle))
        $wExist = WinExists($appTitle)
        
        GUICtrlSetData($prog,$i* 100/20)
        
        If ($wExist = 1) Then
            ExitLoop(1)
        EndIf
        
        $i += 1
    WEnd
    
    If ($wExist = 1) Then
        GUICtrlSetData($prog,100)
        GUICtrlSetData($label,"Success!")
        Sleep(1000)
    EndIf
    
    
EndFunc

Any ideas on a fix? ;)

Link to comment
Share on other sites

It exists because your own window has that title. Now try asking a hard question.

LOL! I hate when I miss something stupid like that.... The only problem now is that i really want that to be in the title because it seems like the correct thing to put there.... at least i can see where the problem is. Thanks.

Link to comment
Share on other sites

Examine the window with AU3Info.exe (the AutoIt Window Info Tool) and check it with a more specific advanced specification, like for example: WinExists("[CLASS:#32770; TITLE:LOL CATZ]", "")

See Window Titles and Text (Advanced) in the help file.

;)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...