Jump to content

Get the focused window


Recommended Posts

msgbox(0,"Found it",getfocus())
func getfocus()
    $var = WinList()
    For $i = 1 to $var[0][0]
    ; Only display visble windows that have a title
        If $var[$i][0] <> "" AND IsVisible($var[$i][1]) Then
            If WinActive($var[$i][0]) Then
                return $var[$i][0]
        ;MsgBox(0, "Details", "Title=" & $var[$i][0] & @LF & "Handle=" & $var[$i][1])       
    return -1

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


I dont think that you need some details..


Link to comment
Share on other sites

  • 2 years later...

Sorry if i re take this old post,

Func and WinGetTitle("") work very well.

But i've a question. Is possible to return as applications identifier, .exe name ?

i use Italian version of xp, a lot of exe have name that can generate 'confusion'.

I read about class but also this item give me some limit for little tool that i want to build.

(mouse gesture tool, based on .exe, so anyone can build his macro)

Anyone can help me?

Thank you


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

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...