Jump to content
Sign in to follow this  

HOWTO: Use Window Handles in Visual Studio 2008 (Visual Basic)

Recommended Posts


Here is a demonstration of the usage of handles in Visual Studio 2008 using the Visual Basic language.

This example finds a Notepad window and closes it.

Dim autoit As AutoItX3Lib.AutoItX3 = New AutoItX3Lib.AutoItX3

autoit.AutoItSetOption("WinTitleMatchMode", 2)

Dim whandle As String = autoit.WinGetHandle("Notepad")

autoit.AutoItSetOption("WinTitleMatchMode", 4)

autoit.WinClose("[HANDLE:" & whandle.Substring(whandle.Length - 8, 8) & "]")

Note the trimming of the whandle string to the last 8 characters (32-bits). This is because WinGetHandle() seems to return 16 character (64-bit) handles under 64-bit operating systems. Tested under Windows XP Pro x64 Edition, 64-bit window handles were not compatible with AutoItX's window matching functions.

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