Jump to content
Sign in to follow this  
Quinch

Getting the currently active window?

Recommended Posts

Quinch

Is there a function that retrieves the information about the currently active window, i.e. title, text, etc.? So far all commands I can find are to see if a specific window exists and things to do to it.

Share this post


Link to post
Share on other sites
UEZ

Try this:

$aWinList = WinList()
For $i = 1 To $aWinList[0][0]
    If BitAnd(WinGetState($aWinList[$i][1]), 8) Then ;get active window
        $aWinPos = WinGetPos($aWinList[$i][1])
        MsgBox(0, "Test",   "Window Titel: " & $aWinList[$i][0] & @LF & _
                                        "Window Handle: "& $aWinList[$i][1] & @LF & _
                                        "Window Position: " & @LF & _
                                        @TAB & @TAB & "x: " & $aWinPos[0] & @LF & _
                                        @TAB & @TAB & "y: " & $aWinPos[1] & @LF & _
                                        @TAB & @TAB & "w: " & $aWinPos[2] & @LF & _
                                        @TAB & @TAB & "h: " & $aWinPos[3] & @LF & _
                                        "Window Class List: " & @LF & WinGetClassList($aWinList[$i][1]))
        ExitLoop
    EndIf
Next

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites
martin

Maybe a little shorter/quicker would be

$hWinActive = WinGetHandle("[ACTIVE]")
$aWinPos = WinGetPos($hWinActive)
MsgBox(0, "Test", "Window Titel: " & WinGetTitle($hWinActive) & @LF & _
        "Window Handle: " & $hWinActive & @LF & _
        "Window Position: " & @LF & _
        @TAB & @TAB & "x: " & $aWinPos[0] & @LF & _
        @TAB & @TAB & "y: " & $aWinPos[1] & @LF & _
        @TAB & @TAB & "w: " & $aWinPos[2] & @LF & _
        @TAB & @TAB & "h: " & $aWinPos[3] & @LF & _
        "Window Class List: " & @LF & WinGetClassList($hWinActive))

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

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  

×