Jump to content

Using window handles with WinGetText


Ryan H.
 Share

Recommended Posts

Using the c# code below, I am attempting to use a window handle to get the Windows title by using the WinGetTitle function.

string handle = auto.WinGetHandle("Test Window Title", string.Empty);

auto.AutoItSetOption("WinTitleMatchMode", 4);

string text = auto.WinGetTitle(handle, string.Empty);

When this code executes, the WinGetTitle method is consistently returning a value of 1. What am I doing wrong?

Thanks for the help,

Ryan

Link to comment
Share on other sites

  • 2 weeks later...

I thought a Window handle could be used instead of a Window title in any of the matching modes. The help topic entitled "Window Titles and Text (Advanced)" includes the following statement: "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."

----------

Edited by Jamal Mazrui
Link to comment
Share on other sites

I thought a Window handle could be used instead of a Window title in any of the matching modes. The help topic entitled "Window Titles and Text (Advanced)" includes the following statement: "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."

----------

You can use a handle in every function that asks for a window title, however only if WinTitleMatchMode is set to 4. And the handle in the window title string has to be in the format "handle=" + WHND, where WHND is a hexadecimal string of no more than 8 hex digits. Examples: "handle=0d0d080", "handle=045e0" . You can obtain WHND from autoitx WinGetHandle as a hex string, or from Shell.Application or from WSHExtend and need to convert it to a hex string.

Link to comment
Share on other sites

What you say may be the intent of the developers, but it is consistent with neither the documentation I referenced nor my testing of code. Specifically, I used the window handle returned from GuiCreate as a parameter to WinMove to resize a form before showing it. No error resulted and the window was resized, whether match mode was 1 or 4.

Link to comment
Share on other sites

What you say may be the intent of the developers, but it is consistent with neither the documentation I referenced nor my testing of code. Specifically, I used the window handle returned from GuiCreate as a parameter to WinMove to resize a form before showing it. No error resulted and the window was resized, whether match mode was 1 or 4.

You're right but in the wrong subforum. Here is AutoItX. Your quotes and test results are from Autoit resp. consistent with AutoIt.

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