module to find handles

You can talk about VB programming here

module to find handles

Postby autopilot » Thu Mar 17, 2011 3:12 pm


A while back, I had shared a module (mdlGetHnd.vb) I created to make finding handles a bit easier. Well I will now share a more compact, cleaner module I have developed to do the same thing. To use it, add the module to you VB 2008 project and then call into it. It has 3 public functions:
    FindMainWindow(wndclass, title)
    GetChild(MainClass, MainCaption, ChildClass, ChildIndex)
    GetChild(ParentHandle, ChildClass, ChildIndex)

For demonstration purposes, if you wanted to find the "Edit" window of NotePad, you could do it this way:
Code: Select all
        Dim sClass As String = "Notepad"
        Dim sCaption As String = "- Notepad"
        Dim sSubClass As String = "Edit"
        Dim iSubIndex As Integer = 1
        Dim wHnd As IntPtr = mdlHnd.GetChild(sClass, sCaption, sSubClass, iSubIndex)

Or you can split it like this:
Code: Select all
        Dim sClass As String = "Notepad"
        Dim sCaption As String = "- Notepad"
        Dim sSubClass As String = "Edit"
        Dim iSubIndex As Integer = 1
        Dim wHndParent As IntPtr = mdlHnd.FindMainWindow(sClass, sCaption)
        Dim wHnd As IntPtr = mdlHnd.GetChild(wHndParent, sSubClass, iSubIndex)


So those who have used my mdlGetHnd should be used to the needed variables.
Attachments
mdlHnd.zip
mdlHnd
(1.89 KiB) Downloaded 44 times
User avatar
autopilot
Forum Moderator
Forum Moderator
 
Posts: 358
Joined: Sat Sep 23, 2006 7:19 pm

Re: module to find handles

Postby String » Thu Mar 17, 2011 8:20 pm

Handy and helpful, well done.
-= Please ask your questions in the forum, not in pm.
String
imFiles Senior
imFiles Senior
 
Posts: 313
Joined: Mon Mar 10, 2008 7:06 am
Location: IDE

Re: module to find handles

Postby Departure » Sat Mar 19, 2011 10:27 pm

Nice work Autopilot, And good to see your still around. btw where in states are you again? I'm over here in new Orleans for awhile.
User avatar
Departure
Global Moderator
Global Moderator
 
Posts: 996
Joined: Thu Mar 17, 2005 11:26 am
Location: Australia

Re: module to find handles

Postby autopilot » Tue Mar 22, 2011 7:13 am

Great to hear from you Dep!
Departure wrote:I'm over here in new Orleans for awhile.

i am in Des Moines, Iowa.
User avatar
autopilot
Forum Moderator
Forum Moderator
 
Posts: 358
Joined: Sat Sep 23, 2006 7:19 pm


Return to Visual Basic Programming

 


  • Related topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 0 guests