Sign in to follow this  
Followers 0
medic

Can I write the window handle into the AutoIt-Script?

5 posts in this topic

Hi guys.

I am using AutoIt3 from withhin one of my programs to send keys to other programs.

My question is:

I already have the window handle (integer value) in my program. Can I now write that value into a script file automatically or do I have to use the WindowGetHandle() function?

Share this post


Link to post
Share on other sites



Hi guys.

I am using AutoIt3 from withhin one of my programs to send keys to other programs.

My question is:

I already have the window handle (integer value) in my program. Can I now write that value into a script file automatically or do I have to use the WindowGetHandle() function?

Window handle is assigned uniquely or randomly when a window is created.

So, next time if you execute a process, the process' window-handle will most likely be different than before. Therefore, it is needed to get the handle each time to make sure that the handle is correct.

If you want you could use Window class name but, 2 windows can have the same class name, like notepad windows. Or you could use window title. And I suggest, use AutoIt AU3Info tool to check things.

Good luck.

Share this post


Link to post
Share on other sites

Window handle is assigned uniquely or randomly when a window is created.

So, next time if you execute a process, the process' window-handle will most likely be different than before. Therefore, it is needed to get the handle each time to make sure that the handle is correct.

If you want you could use Window class name but, 2 windows can have the same class name, like notepad windows. Or you could use window title. And I suggest, use AutoIt AU3Info tool to check things.

Good luck.

Yeah I know that. I already retrieve the target window's handle at runtime and only milliseconds later I want to use the very same handle in the AutoIt script. So my question is: can I just write it into the autoIt script?

Share this post


Link to post
Share on other sites

So my question is: can I just write it into the autoIt script?

Yes you can.

Example the handle is: 0x1234e. You need to use WinGetHandle("0x1234e") first.

Here's the script example:

$a= InputBox("","Insert Handle")
$a=WinGetHandle($a)
Msgbox(0,0,WinGetTitle($a,""))

Share this post


Link to post
Share on other sites

All that's needed is casting the number with (HWnd(0x1234e)), but still be aware it will stop working when you close the program window.

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