Jump to content

Getting the currently active window?


 Share

Recommended Posts

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

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.
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...