Jump to content

WinActivated


olivarra1
 Share

Recommended Posts

I searched a Function that gives me the handle and the tittle of the active window and i haven't found it, so I made it. it took me few minutes:

Func _WinActivated()
    Local $return[2]
    Local $windows = WinList()
    Local $i
    
    for $i = 1 to $windows[0][0]
        if Winactive($windows[$i][1]) then
            $return[0] = $windows[$i][0]
            $return[1] = $windows[$i][1]
            ExitLoop
        EndIf
        if $i = $windows[0][0] Then
            $return[0] = -1
            $return[1] = -1
        EndIf
    Next
    Return($return)
EndFunc

It returns an array, $return[0] is the window's title and $return[1] is the window's handle. if error, then sets the two values to -1.

olivarra1

Link to comment
Share on other sites

Function WinGetTitle

WinGetTitle("") returns the active window's title.

So, something like this.

Func _Activated ()
Local $sRet[2]
$sRet[0] = WinGetTitle("")
$sRet[1] = WinGetHandle($sRet[0])
Return $sRet
EndFunc

Link to comment
Share on other sites

Function WinGetTitle[ left]WinGetTitle("") returns the active window's title.

mhh autoit help doesn't say it :D

WinGetTitle 
--------------------------------------------------------------------------------
Retrieves the full title from a window.
WinGetTitle ( "title" [ , "text"] )

Parameters
title The title of the window to read. See Title special definition. 
text [ optional] The text of the window to read.

But it's kinda confusing, because how can you know the window's title using a function that asks you the window's title?

well so thank you ^^

olivarra1

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