Jump to content

Cannot "reuse" control handle in DLL (not using COM)


Markos
 Share

Recommended Posts

If used directly in AutoIt, we can use:

$hWnd  = WinGetHandle("some window", "")
$hCtrl = ControlGetHandle($hWnd, "", "some control")

ControlClick("", "", $hCtrl)

This simply works, however if I want to do the same from DLL, to use handles, we have to use the [HANDLE:] advanced window description:

var hWnd  = AU3_WinGetHandle("some window", "");
var hCtrl = AU3_ControlGetHandle("[HANDLE:" + hWnd + "]", "", "some control");    //this WORKS, but we have to use the HANDLE:, to tell autoit that it is a handle, not just a text

//now I want to do line 3 from previous example:
AU3_ControlClick("", "", [HANDLE:" + hCtrl + "]");  //this does NOT WORK while the same code in autoit does.

//I have also tried to use just the handle; to use WinTitleMatchMode=3 and "handle="+hCtrl, but always no luck.

(example is simplified to demonstrate the problem, I know that I have to use buffer to get return values)

(the issue isnt getting ControlClick to work, but to get the hCtrl to work; using ControlClick without using handle does work of course)

Is this part unimplemented in the autoit dll? Or do I have to do something special?

Maybe this is a bug? Maybe it is on purpose?

Or I am just too tired to see what is wrong?

I just need to use handles, because I am doing a search in messy window. The only workaround that comes to me right now would be to find the control and get its ID, then rerference it as (windowHandle, controlID) tuple. But I have no idea how would I get the ID. And the control hwnd would still suit me better, because i wouldnt need to reference the control using also window handle.

I am looking forward to see your suggestions.

Markos

Link to comment
Share on other sites

  • 1 month later...

You are not sending HANDLE as a string. Try something like

AU3_ControlClick("", "", "[HANDLE:" + hCtrl + "]"") or (depending on the language)
AU3_ControlClick("", "", '[HANDLE:" + hCtrl + "]"')
Edited by bo8ster

Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Link to comment
Share on other sites

  • 1 month later...

You are not sending HANDLE as a string. Try something like

AU3_ControlClick("", "", "[HANDLE:" + hCtrl + "]"") or (depending on the language)
AU3_ControlClick("", "", '[HANDLE:" + hCtrl + "]"')

Actually I tried just what you suggest and it doesn't seem to work.

Assuming

(1) the control name is "Edit" and the instance is 1 and "CtlHwnd" its valid handle is in the form "[HANDLE:cccccccc]".

(2) the variable "WinHwnd" contains valid window handle in the form "[HANDLE:wwwwwwww]"

I tried the following in C#:

AU3_ControlFocus(WinHwnd, "", CtlHwnd, sbArea, 32);

nothing happens.

However, if I use the following everything works fine:

AU3_ControlFocus(WinHwnd, "", "[CLASSNN:Edit1]", sbArea, 32);

But, I already have the control handle and would like to use it directly.

Does the [HANDLE:xxxxx} construct exist in AutoIt for Control ids as it does for Window titles?

If not, how does one forward a request to the developers to add such construct?

Regards,

Jim

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