Jump to content

winwaitactive title changes


mud409
 Share

Recommended Posts

I'm trying to retrieve the title of a window which the title changes... If I put the exact title name of the window in it works fine except that there's a time period in which the "mystery title" window will be logging in and establish that it's ready with "<Client> Connected!" under the ClassnameNN "RICHEDIT1"

Is there any way of detecting this title name (none of it stays the same, so I can't even grab a partial title) and waiting till the window indicates that it's ready?

Func serverlaunch()
        WinWait("SupraclientCPPE http://www.StrussersList.com", "")
        If Not WinActive("SupraclientCPPE http://www.StrussersList.com", "") Then WinActivate("SupraclientCPPE http://www.StrussersList.com", "")
        WinWaitActive("SupraclientCPPE http://www.StrussersList.com", "")
        Opt("WinTitleMatchMode", 2)
        ControlFocus ("SupraclientCPPE http://www.StrussersList.com", "", "Edit10")
        ControlSetText ("SupraclientCPPE http://www.StrussersList.com", "", "Edit10", $ctrlread)    
        ControlClick ("SupraclientCPPE http://www.StrussersList.com", "", "Button18")
        Opt("WinTitleMatchMode", 2)
        WinWait("GodWeapons's Best of the Best EmulinkerSF Server", "")
        If Not WinActive("GodWeapons's Best of the Best EmulinkerSF Server", "") Then WinActivate("GodWeapons's Best of the Best EmulinkerSF Server", "")
        WinWaitActive("GodWeapons's Best of the Best EmulinkerSF Server", "")
        $gamename = IniRead (@scriptdir & "\fesettings.ini", "settings", "lastgameread", "")
        ControlSetText ("GodWeapons's Best of the Best EmulinkerSF Server", "", "Edit3", $gamename)
        ControlClick ("GodWeapons's Best of the Best EmulinkerSF Server", "", "Button8")
EndFunc

Now the section that says GodWeapon's is the title that will change depending on the server it connects to, which all depends on which server IP I enter... And I haven't implemented any code that waits for when RICHEDIT1 states "<Client> Connected!" before it ControlClicks "Button8".

Link to comment
Share on other sites

If there is a static title it starts with that you know of, then you can get the PID/Handle and just poll the wintitle until it changes:

$hWnd_MysteryWindow = WinGetHandle("Mysterywindow.com")
$sz_CurrentTitle = WinGetTitle($hWnd_MysteryWindow)

AdlibEnable("Poll_MysteryWindow",250)

Func Poll_MysteryWindow()
     If (WinGetTitle($hWnd_MysteryWindow) <> $sz_CurrentTitle) Then
          MsgBox(0,"It changed!","Do something! QUICK! I like pie...")
     EndIf
EndFunc

-CMR

Link to comment
Share on other sites

Hi,

try using handle or play with WinTitleMatchMode 1-4 if there is any static part in the title.

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Func serverlaunch()
    
        WinWait("SupraclientCPPE http://www.StrussersList.com", "")
        If Not WinActive("SupraclientCPPE http://www.StrussersList.com", "") Then WinActivate("SupraclientCPPE http://www.StrussersList.com", "")
        WinWaitActive("SupraclientCPPE http://www.StrussersList.com", "")
        $hWnd_MysteryWindow = WinGetHandle("SupraclientCPPE http://www.StrussersList.com")
$sz_CurrentTitle = WinGetTitle($hWnd_MysteryWindow)
        Opt("WinTitleMatchMode", 2)
        ControlFocus ("SupraclientCPPE http://www.StrussersList.com", "", "Edit10")
        ControlSetText ("SupraclientCPPE http://www.StrussersList.com", "", "Edit10", $ctrlread)    
        
        ControlClick ("SupraclientCPPE http://www.StrussersList.com", "", "Button18")
        Opt("WinTitleMatchMode", 2)
AdlibEnable("Poll_MysteryWindow",250)
    EndFunc
    
    Func Poll_MysteryWindow()
     If (WinGetTitle($hWnd_MysteryWindow) <> $sz_CurrentTitle) Then
          $gamename = IniRead (@scriptdir & "\fesettings.ini", "settings", "lastgameread", "")
        ControlSetText ($hWnd_MysteryWindow, "", "Edit3", $gamename)
        WinWait( $hWnd_MysteryWindow, "<Client> Connected!", 10 )
        ControlClick ($hWnd_MysteryWindow, "", "Button8")
     EndIf
EndFunc

errors with

Line 594 (File "C:\frontend\mfelauncher3.au3"):

If (WinGetTitle($hWnd_MysteryWindow) <> $sz_CurrentTitle) Then

If (WinGetTitle(^ ERROR

Error: Variable used without being declared.

Link to comment
Share on other sites

Try this (you need to edit $sClass to match your pop up):

Opt("WinTitleMatchMode", 4)
$sClass = "#32770"
$avWinList = WinList("[CLASS:" & $sClass & "]")
$iFound = 0
For $n = 1 To $avWinList[0][0]
    $sText = ControlGetText($avWinList[$n][1], "", "RICHEDIT1")
    If @error Then ContinueLoop
    If StringInStr($sText, "<Client> Connected!") Then
        $iFound = $n
        ExitLoop
    EndIf
Next
If $iFound Then
    ConsoleWrite("Title:  " & $avWinList[$iFound][0] & @LF & _
            "hWND:  " & $avWinList[$iFound][1] & @LF & _
            "Text:  " & $sText & @LF)
Else
    ConsoleWrite("Window not found.")
EndIf

:)

Edit: Fix window class pattern.

Edited by PsaltyDS
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

Func serverlaunch()
        WinWait("SupraclientCPPE [url="http://www.StrussersList.com""]http://www.StrussersList.com"[/url], "")
        If Not WinActive("SupraclientCPPE [url="http://www.StrussersList.com""]http://www.StrussersList.com"[/url], "") Then WinActivate("SupraclientCPPE [url="http://www.StrussersList.com""]http://www.StrussersList.com"[/url], "")
        WinWaitActive("SupraclientCPPE [url="http://www.StrussersList.com""]http://www.StrussersList.com"[/url], "")
        Opt("WinTitleMatchMode", 2)
        ControlFocus ("SupraclientCPPE [url="http://www.StrussersList.com""]http://www.StrussersList.com"[/url], "", "Edit10")
        ControlSetText ("SupraclientCPPE [url="http://www.StrussersList.com""]http://www.StrussersList.com"[/url], "", "Edit10", $ctrlread) 
        ControlClick ("SupraclientCPPE [url="http://www.StrussersList.com""]http://www.StrussersList.com"[/url], "", "Button18")
        Opt("WinTitleMatchMode", 2)
        
        Opt("WinTitleMatchMode", 4)
        $sClass = "Supraclient"
        $avWinList = WinList("[CLASS:" & $sClass & "]")
        $iFound = 0
        For $n = 1 To $avWinList[0][0]
        $sText = ControlGetText($avWinList[$n][1], "", "RICHEDIT1")
        If @error Then ContinueLoop
        If StringInStr($sText, "<Client> Connected!") Then
        $iFound = $n
        ExitLoop
    EndIf
Next
If $iFound Then
        $gamename = IniRead (@scriptdir & "\fesettings.ini", "settings", "lastgameread", "")
        ControlSetText ($sText, "", "Edit3", $gamename)
        ControlClick ($sText, "", "Button8")
Else
    MSGBOX (1, "Window not found.", $sText)
EndIf

        
    EndFunc

it goes to else msg box and then $sText reports the first 2 lines of RICHEDIT1

Edited by mud409
Link to comment
Share on other sites

it goes to else msg box and then $sText reports the first 2 lines of RICHEDIT1

And "supraclient" is the window class reported by AU3Info.exe?

Also, is that literal text "<Client> Connected!" correct in the StringInStr() check for a match?

:)

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

Supraclient is what is reported from info...

<Client> Disconnected!

<Client> Resolving host...

<Client> Connecting...

<Client> Gathering Users and Games...

<Client> Connected!

that's the raw text from the window info when connecting

the msg box responds with

<Client> Disconnected!

<Client> Resolving host...

window info says

>>>> Window <<<<

Title: 65.99.246.10:27888

Class: Supraclient

Position: 134, 289

Size: 800, 600

Style: 0x14CA0000

ExStyle: 0x00000100

Handle: 0x001102BA

Edited by mud409
Link to comment
Share on other sites

Supraclient is what is reported from info...

<Client> Disconnected!

<Client> Resolving host...

<Client> Connecting...

<Client> Gathering Users and Games...

<Client> Connected!

that's the raw text from the window info when connecting

the msg box responds with

<Client> Disconnected!

<Client> Resolving host...

window info says

>>>> Window <<<<

Title: 65.99.246.10:27888

Class: Supraclient

Position: 134, 289

Size: 800, 600

Style: 0x14CA0000

ExStyle: 0x00000100

Handle: 0x001102BA

Is it still at the "Resolving host..." point when that part of the script runs? Are you checking repeatedly in a loop until "Connected!" shows up? It looks like you only check once, and maybe thats as far as it has gotten by that time.

:)

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

I thought it was looping... I'm confused now.

The only loop in the code from post #8 is the one that checks each current window ONCE for the text. If, at that point in time, the "Connected!" message hasn't occurred then it won't find it and you'll have to check again until it does.

I would rather refine the process of identifying the correct window in the first place and only loop on checking that one window, but since you're the only one who has this app, only you know what unique properties might identify this pop up from all others.

:)

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

oh you can get the program no problem... it's all public freeware... the version I have of the kailleraclient is slightly customized but the default version has everything needed to check the script (the part I'm trying to get working at least)

supraclient is a kailleraclient.dll. this is the program thats being scripting

then you need mame or some other kaillera enabled program to launch the kailleraclient like Mame64

as well I made a correction earlier that you might have missed, it's not actually a popup, I thought it was at first cause that's how it used to be.

Edited by mud409
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...