Sign in to follow this  
Followers 0
kjcdude

WinGetTitle Issue

3 posts in this topic

#1 ·  Posted (edited)

I'm running into a very strange issue. It looks like a bug, but I'm not entirely sure.

Here's the code with the error.

while 1
    local $ct = WinGetTitle("Steam - Updating -", "")
    sleep(30000)
    SplashTextOn("", "$CT = " & $ct & @CRLF & "Wingettitle = " & WinGetTitle("Steam - Updating -", ""), 300, 100, -1, -1, 16, "Veranda", 9)
    Select
        Case WinGetTitle("Steam - Updating -", "") = $ct
            if WinGetTitle("Steam - Updating -", "") = $ct Then
                MsgBox(0, "TRUE", "$CT = " & $ct & @CRLF & "Wingettitle = " & WinGetTitle("Steam - Updating -", ""))
            Else
                MsgBox(0, "FALSE", "$CT = " & $ct & @CRLF & "Wingettitle = " & WinGetTitle("Steam - Updating -", ""))
            EndIf
            ProcessClose("steam.exe")
            FileDelete("C:\Program Files\Steam\ClientRegistry.blob")
            FileDelete("C:\Program Files\Steam\AppUpdateStats.blob")
            ShellExecuteWait("SteamService.exe", "/repair", "C:\Program Files\Steam\bin")
            run($gsteamlauncher)
            ExitLoop
        Case WinExists("Steam - Updating -", "") = 0
            ExitLoop
    EndSelect
WEnd

What will occur is it will provide a false positive.

If the window is no longer open it will output 0 like it should, but case and the if statements return a TRUE result meaning "Steam - Updating - 81%" = "0" which it obviously doesn't.

When there is an active title it will react correctly and provide a false statement as it should.

As a temporary fix I changed the Case line to.

Case WinGetTitle("Steam - Updating -", "") = $ct and WinGetTitle("Steam - Updating -", "") <> 0

See the attached screenshot for an example of the error.

post-29143-1259368040534_thumb.jpg

Edited by kjcdude

Share this post


Link to post
Share on other sites



kjcdude,

I feel that it is a logic problem in your code rather then a bug. For example:

Case WinGetTitle("Steam - Updating -", "") = $ct
        If WinGetTitle("Steam - Updating -", "") = $ct Then

If we get ito the Case code, it is because WinGetTitle("Steam - Updating -", "") = $ct, so why the identical If which follows? :)

I have written a new loop and tested it against a window that updates the title on a regular basis (actually every second and with the Sleep reduced to 3 secs). It identified all 3 states correctly (updating, stalled, ended):

While 1

    ; Store current window title
    Local $ct = WinGetTitle("Steam - Updating -", "")
    ; Wait for 30 secs
    Sleep(30000)

    ; Deal with the exit case first
    If Not WinExists("Steam - Updating -", "") Then ExitLoop
    ; We know window exists if we get here

    ; See if title has changed
    If WinGetTitle("Steam - Updating -", "") = $ct Then
        ; No change - so I assume you are going to run the /repair code here
        ConsoleWrite("Stuck - Valve has failed!" & @CRLF)
    Else
        ; Change - so you could either update your Splashtext or just contimue
        ConsoleWrite("Steaming away! " & $ct & @CRLF)
    EndIf

WEnd

ConsoleWrite("No more Steam - fire the stoker!" & @CRLF)

I hope that it helps in your project. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

The reason for the extra if statement was to confirm twice for debugging out to the msgbox.

The actual code is this:

while 1
    local $ct = WinGetTitle("Steam - Updating -", "")
    sleep(30000)
    Select
        Case WinGetTitle("Steam - Updating -", "") = $ct
            ProcessClose("steam.exe")
            FileDelete("C:\Program Files\Steam\ClientRegistry.blob")
            FileDelete("C:\Program Files\Steam\AppUpdateStats.blob")
            ShellExecuteWait("SteamService.exe", "/repair", "C:\Program Files\Steam\bin")
            run($gsteamlauncher)
            ExitLoop
        Case WinExists("Steam - Updating -", "") = 0
            ExitLoop
    EndSelect
WEnd

I'll definitely try your suggestion, it looks to be a lot cleaner and more efficient than mine.

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