Sign in to follow this  
Followers 0
Ármányos Kő

WinWaitNew_GetTitle

5 posts in this topic

#1 ·  Posted (edited)

I made some script which brings up different Sub-windows by keyboard shortcuts. I mean windows like Paste Special, Open, ... These windows do have different titles under different language OS.

So the question came how to manipulate these windows by title reference, if not nowing the name?

Even, how to WinWaitActive if not knowing the title?

The answer is below.

Maybe it is some use of someone.

(Basically the script in this form is a try to make a quasi-UDF, it's a bit dodgy, I am not expert in ByRef functioning yet.)

#Include <Constants.au3>
#Include <Array.au3>
#include <file.au3>
#include <GUIConstants.au3>




Func WinWaitNew_GetTitle(ByRef $NT)
    $NT = ""
    
    Do
        Sleep(50)
        $PostList = WinList()
    Until $PostList[0][0] <> $WinWaitNew_Start[0][0]
    
    For $i = 1 to $PostList[0][0]
        If $PostList[$i][0] <> "" AND IsVisible($PostList[$i][1]) Then
        $NT = $NT&$PostList[$i][0]
        EndIf
    Next

    For $i = 1 to $WinWaitNew_Start[0][0]
        If $WinWaitNew_Start[$i][0] <> "" AND IsVisible($WinWaitNew_Start[$i][1]) Then
        $NT = StringReplace($NT, $WinWaitNew_Start[$i][0],"", 1,1)
        EndIf
    Next    
EndFunc

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



;Testing the functions

AutoItSetOption("WinTitleMatchMode", 2)
    $NewTitle = ""

Run("notepad.exe")
WinWaitActive("Notepad", "")
$WinWaitNew_Start = WinList()   ;Start watching right before bringing up new window with some action
Send ("^o")               ;This action brings up the new window, which we do not know the title of
WinWaitNew_GetTitle($NewTitle)  ;Get the title of the new window
MsgBox(0, "The title", "Your title of OPEN window is: "&@CRLF&@TAB&$NewTitle)
MsgBox(0, "The title", "Now you can reference to this window with $NewTitle and perform actions with ControlClick and others")

WinActivate ($NewTitle, "")
WinWaitActive( $NewTitle, "")
ControlClick ($NewTitle, "", "ComboBox2")
Sleep(1000)
ControlClick ($NewTitle, "", "ComboBox3")
Sleep(1000)
ControlClick ($NewTitle, "", "ComboBox4")
Sleep(1000)
WinClose( $NewTitle, "")
Sleep(500)
WinClose("Notepad", "")

Edit: added codetags

Edited by JdeB

Share this post


Link to post
Share on other sites



Share this post


Link to post
Share on other sites

Whhoooaa....I've been searching for this example long time ago...

Thanks 4 sharing :)


AUTOIT[sup] I'm lovin' it![/sup]

Share this post


Link to post
Share on other sites

Hi!

Thanks you, for this good sample/script.

One info: for french language, replace the line

WinWaitActive("Notepad", "")

by

WinWaitActive("Bloc-notes", "")

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