Sign in to follow this  
Followers 0
ATExplorer

How to send keys, knowing the handle rather than the title.

5 posts in this topic

Hi,

I'm using the COM component, and specifically the WinActivate & Send functions. During the initialization of the app, I set 2 static window handles to be the target of various operations - copy & pasting, writing various status information, etc. Both handles are text editors, NotePad++ e.g. or UltraEdit.

The handles of course remain the same, throughout. But since information is added to them, the titles changes slightly, because the content changes, resulting in an asterisk '*' in the title. I don't want to do a File Save during the running of the app, which would remove the asterisk.

So in other words, if the initial handle for one of the static windows is 525662, and the initial title is

[C:\AutoitTestFiles\NOTE20120707.TXT] - UEStudio '12,

then after some lines are written to this file, the title will become

[C:\AutoitTestFiles\NOTE20120707.TXT*] - UEStudio '12 (notice the asterisk).

The problem is, when I try to send using the current asterisked title,

::oAutoIt:WinActivate( sSourceTitle ) no longer works, because the sSourceTitle variable does not contained the asterisked version of the window title.

I know you can set options for WinActivate & similar functions to take a wildcarded version of the title. I'll settle for that, if necessary. But is there an AutoIt function that can re-retrieve the current title of a window, given the handle?

Thanks for any suggestions, even if it's a 'no, sorry'.

Regards,

Share this post


Link to post
Share on other sites



And yes, I did try using the handles in place of the title. In that case, the WinActivate Function returns empty, and doesn't activate the window.

Hi,

I'm using the COM component, and specifically the WinActivate & Send functions. During the initialization of the app, I set 2 static window handles to be the target of various operations - copy & pasting, writing various status information, etc. Both handles are text editors, NotePad++ e.g. or UltraEdit.

The handles of course remain the same, throughout. But since information is added to them, the titles changes slightly, because the content changes, resulting in an asterisk '*' in the title. I don't want to do a File Save during the running of the app, which would remove the asterisk.

So in other words, if the initial handle for one of the static windows is 525662, and the initial title is

[C:AutoitTestFilesNOTE20120707.TXT] - UEStudio '12,

then after some lines are written to this file, the title will become

[C:AutoitTestFilesNOTE20120707.TXT*] - UEStudio '12 (notice the asterisk).

The problem is, when I try to send using the current asterisked title,

::oAutoIt:WinActivate( sSourceTitle ) no longer works, because the sSourceTitle variable does not contained the asterisked version of the window title.

I know you can set options for WinActivate & similar functions to take a wildcarded version of the title. I'll settle for that, if necessary. But is there an AutoIt function that can re-retrieve the current title of a window, given the handle?

Thanks for any suggestions, even if it's a 'no, sorry'.

Regards,

Share this post


Link to post
Share on other sites

If somewhere along the lines your handle is getting converted to a string (maybe before finishing, your script outputs it for another script to pick up where the first left off or something), you can use the hwnd() function to convert it back to a handle object.

http://www.autoitscript.com/autoit3/docs/functions/HWnd.htm

And as for getting the full title from a partial title or handle, use:

http://www.autoitscript.com/autoit3/docs/functions/WinGetTitle.htm

And if all else fails, if you didn't set the mode that requires the full title, and you can predict or compute everything before the asterisk, then just use "[C:AutoitTestFilesNOTE20120707.TXT" before and after the changes are made to the file and the asterisk appears since the default mode for window titles is prefix.

Share this post


Link to post
Share on other sites

There is no hwnd() function in AutoItx3.

I cannot remember where I read it, but as I recall you must pass the string

representation of the handle/hwnd value of a window to the Win* functions

used.

Alternatively you could employ AutoItSetOption, with WinTitleMatchMode set to 2.


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

Arity and JohnOne,

Thanks for the suggestions. I just found out this morning that a Winapi function is available to the language I'm using. The function is GetWindowText( hwnd ), and this is what I need.

There is no hwnd() function in AutoItx3.

I cannot remember where I read it, but as I recall you must pass the string

representation of the handle/hwnd value of a window to the Win* functions

used.

Alternatively you could employ AutoItSetOption, with WinTitleMatchMode set to 2.

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