Sign in to follow this  
Followers 0
h711

How to ID same class dialog boxes without using Text Strings?

8 posts in this topic

It looks like Window dialog boxes usually have Class: #32770. I need to id these boxes without using any text for functions like "WinWaitActive" or "WinActive". Since these functions take no condtrol ID but only "title", I need something to help id it besides Class: #32770. I cannot use dialog box's title text or any text on it, because I need my program to run on multiple OSes in different languages.

A quick test is to open "Phone and Modens Options" and "Game Controls" dialog boxes from Control Panel and see if there is a way to ID them without using any text string.

Thanks for the help!

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Ok, I ask this in a different way.

Can you setup a logic that functions like WinWaitActive, but it check the window for buttons, Edit, window style... then decide if the right window is found and wait ends?

Edited by h711

Share this post


Link to post
Share on other sites

Ok, I ask this in a different way.

Can you setup a logic that functions like WinWaitActive, but it check the window for buttons, Edit, window style... then decide if the right window is found and wait ends?

Look at all the "Win" functions in AutoIt. You should be able to get the 'Classlist'(Controls), the title, position, the process, ect. :)

Share this post


Link to post
Share on other sites

Please do me a favor, could you give me an example of:

1, If a window only has 2 buttons, condition met and wait ends.

2, If the Sytle: 0x96C80284, then the right window found and wait ends.

Any one of the above is fine. I need some idea to get myself pass this.

Thanks for the help!

Share this post


Link to post
Share on other sites

Please do me a favor, could you give me an example of:

1, If a window only has 2 buttons, condition met and wait ends.

2, If the Sytle: 0x96C80284, then the right window found and wait ends.

Any one of the above is fine. I need some idea to get myself pass this.

Thanks for the help!

Np. Here ya go!

#include <Constants.au3>
#include <WinAPI.au3>
;


$APIGET = _WinAPI_GetWindowLong(WinGetHandle("AutoIt Help"), $GWL_STYLE)
MsgBox(0,  "", Hex($APIGET)) ; Style

$Array = WinGetClassList("AutoIt Help")
$Array = StringSplit($Array, @CRLF)
$iNumofButtons = 0
For $I = 1 To $Array[0] 
    If StringInStr($Array[$I], "Button") >= 1 Then $iNumofButtons += 1
Next

MsgBox(0, "", $iNumofButtons)

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Thanks!!!!!!!!!!

Just one more question, can I replace "AutoIt Help" with the current active window (the most top one)? Assume I don't know which window is the active one and the title of that window, so I can use this logic to the check the active window's style until match found.

Edited by h711

Share this post


Link to post
Share on other sites

Thanks!!!!!!!!!!

Just one more question, can I replace "AutoIt Help" with the current active window (the most top one)? Assume I don't know which window is the active one and the title of that window, so I can use this logic to the check the active window's style until match found.

You can if you like.

Another cool command is "WinList". It creates an array of every window currently running. Not only does it give you the text but it also gives you the handle.

Here is an example of how I used it for an old "Xfire" bot:

$Timer = TimerInit()

While 1

    $list = WinList()
    For $I = 1 to $list[0][0]
        
        If StringInStr($list[$I][0], "- Chat Window") >= 1  AND IsVisible($list[$I][1]) Then 
            ;MsgBox(0, "", $list[$I][0])
            WinActivate($list[$I][1])
            $Name = StringRegExp($list[$I][0], "(.*) -", 1)
            Send("Hey " & $Name[0] & ". I'm currently AFK=) Time AFK: " & Round((TimerDiff($Timer) / 1000), 1) & " seconds")
            Send("{ENTER}")
            WinClose($list[$I][1])
            ExitLoop
        EndIf

    Next

    Sleep(1000)

WEnd

Func IsVisible($handle)
  If BitAnd( WinGetState($handle), 2 ) Then 
    Return 1
  Else
    Return 0
  EndIf

EndFunc

It sits there and loops through all the windows until it finds a new "Chat window". It grabs the persons name and replies back to them :)

Share this post


Link to post
Share on other sites

You Rock!!!!!!!!!

Thanks for the help!

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