Sign in to follow this  
Followers 0
Jon310

Using Handles in ControlSend

6 posts in this topic

I was reading this in the helpfile and was wondering how the handle could be used in the application described.

Window Handles / HWNDs

The variant datatype in AutoIt natively supports window handles (HWNDs). A window handle is a special value that windows assigns to a window each time it is created. When you have a handle you may use it in place of the title parameter in any of the function calls that use the title/text convention. The advantage of using window handles is that if you have multiple copies of an application open - which have the same title/text - you can uniquely identify them when using handles. When you use a window handle for the title parameter then the text parameter is completely ignored.

Various functions such as WinGetHandle, WinList and GUICreate return these handles. It is important to note that a window handle is not classed as a number or string - it is it's own special type.

Would it be used like:

ControlSend(0x000B0750, "", "", "Test")oÝ÷ ØêÚºÚ"µÍÛÛÛÙ[
    ][ÝÌ
ÍL ][ÝË  ][ÝÉ][ÝË    ][ÝÉ][ÝË    ][ÝÕÝ    ][ÝÊ

Or am I looking at it all wrong. Im trying to get it to send to a particular window when many windows of that same name are open.

Share this post


Link to post
Share on other sites



Look at ControlGetHandle ( "title", "text", controlID ) in AutoIt HelpFile

Thanks for the help.

One question. How would it distinguish one instance of say, notepad, versus the other 4 I have running?

Share this post


Link to post
Share on other sites

If WinActive("whatever") Then
    ;do whatever
EndIf

and always use AU3 Info (located in your autoit directory) to see the handle's names.

Kurt


Awaiting Diablo III..

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Also look up WinGetHandle()

you will also want to put this command towards the beginning of your script:

AutoItSetOption("WinTitleMatchMode", 4)

In answer to your second question, each window has a separate and unique handle. If you get the handle of the "Active" notepad, then this handle will always refer to that window, even when it is no longer active (until the window ceases to exits)

Edited by improbability_paradox

Share this post


Link to post
Share on other sites

Also look up WinGetHandle()

you will also want to put this command towards the beginning of your script:

AutoItSetOption("WinTitleMatchMode", 4)

In answer to your second question, each window has a separate and unique handle. If you get the handle of the "Active" notepad, then this handle will always refer to that window, even when it is no longer active (until the window ceases to exits)

Perfect, works like a charm, thanks for all the help.

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  
Followers 0