Jump to content
Sign in to follow this  
JohnBailey

Get Window Title using Handle (HWnd)

Recommended Posts

JohnBailey

How do I get a window title using the a windows handler (Hwnd)?


A decision is a powerful thing

Share this post


Link to post
Share on other sites
PsaltyDS

How do I get a window title using the a windows handler (Hwnd)?

$sTitle = WinGetTitle($hWin)

AutoIt will take a handle in place of the title string to specify a window.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
JohnBailey

$sTitle = WinGetTitle($hWin)

AutoIt will take a handle in place of the title string to specify a window.

:)

OH! I had no idea! I never saw anything about that in the help! Thank you!


A decision is a powerful thing

Share this post


Link to post
Share on other sites
Blue_Drache

And I'm the first person to use the hwnd of a window instead of the title...Titles are mutable and can change. The hwnd does not.


Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites
JohnBailey

And I'm the first person to use the hwnd of a window instead of the title...Titles are mutable and can change. The hwnd does not.

oh absolutely that's a part of the reason why I'm wanting to use them


A decision is a powerful thing

Share this post


Link to post
Share on other sites
Blue_Drache

Just be sure to set Opt("WinTitleMatchMode",4) :)


Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites
JohnBailey

Just be sure to set Opt("WinTitleMatchMode",4) :)

? It's working for me without doing that


A decision is a powerful thing

Share this post


Link to post
Share on other sites
PsaltyDS

Just be sure to set Opt("WinTitleMatchMode",4) ;)

You don't have to do that to use handles, but you do if you want to use "[CLASS:]" style attributes.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
JohnBailey

You don't have to do that to use handles, but you do if you want to use "[CLASS:]" style attributes.

:)

PsaltyDS, that's what I was understanding too.

A decision is a powerful thing

Share this post


Link to post
Share on other sites
SmOke_N

but you do if you want to use "[CLASS:]" style attributes.

:)

Only if you are using the old ways classname=#32770 versus [CLASS:#32770]

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
PsaltyDS

Only if you are using the old ways classname=#32770 versus [CLASS:#32770]

Did not realize that...

I'm done! Go'n home for the day! Learned my new thing for day!

Run("notepad.exe")
$i = 0
Do
    Sleep(20)
    $hWin = WinGetHandle("[CLASS:Notepad; TITLE:Untitled - Notepad]")
    $i += 1
Until IsHWnd($hWin)
MsgBox(64, "Test", "Got handle in " & $i & " tries.")
WinClose($hWin)
$hWin = 0

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
SmOke_N

Did not realize that...

I'm done! Go'n home for the day! Learned my new thing for day!

Run("notepad.exe")
$i = 0
Do
    Sleep(20)
    $hWin = WinGetHandle("[CLASS:Notepad; TITLE:Untitled - Notepad]")
    $i += 1
Until IsHWnd($hWin)
MsgBox(64, "Test", "Got handle in " & $i & " tries.")
WinClose($hWin)
$hWin = 0

:)

I only found out by someone pointing it out to me the other day... guess I missed the "You don't have to anymore post" as well.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
Blue_Drache

Meh, I guess I'm old hat then.

I still set advanced, just in case...and I get the benefits of option 2 when I need to match titles.


Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.