Results 1 to 7 of 7

Thread: Dynamically get handles of other apps controls

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2001
    Posts
    217

    Question Dynamically get handles of other apps controls

    Hi, I'm trying to add the capacity to interact with other application inside my app. More specifically I'm trying to add the capability to "activate" other apps command buttons based off there caption. I know I have to use the api to do this, so far this is where I'm at in the exploration of this concept.

    Some aspects of my programs interaction will always remain true, the most important of which i think is that the window with the buttons and controls i want to activate are always going to be in the active foreground while my app is minimized. So I was thinking i could get the handle with

    Public Declare Function GetForegroundWindow Lib "user32" () As Long

    in a module and

    lngWindowHandle = GetForegroundWindow

    inside my apps form.

    Now that I have the windows handle how do i get all the buttons handles and captions ?

    I was looking at the EnumChildWindows api

    Public Declare Function EnumChildWindows Lib "user32" (ByVal hwndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Any) As Long

    But does this apply to buttons or only windows?

    I do know how to use SendMessage and PostMessage to trigger the event based off the handle, but
    I need to find out how to Get the handle based off the caption.
    So far this is the information i have collected that i think would be helpful in determining the handles of buttons.

    1. Handle of Desired Parent window or window with the controls
    2. Desired Button Caption
    3. Desired action to take.

    If Anyone can give me a few pointers I'd really apreciate it.
    Thanks

    [email protected]

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Feb 2001
    Posts
    217
    *Bump*

    Thanks again guys.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Feb 2001
    Posts
    217
    *Bump*
    Sorry guys, I really need help with this
    [email protected]

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Feb 2001
    Posts
    217
    *Bump*

  5. #5
    Hyperactive Member
    Join Date
    Oct 2001
    Location
    The Netherlands
    Posts
    403
    EnumChildWindows will do fine, it'll enumerate all child windows including buttons (If they aren't just painted, they should have a handle).

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Feb 2001
    Posts
    217
    Could you maybe post a proper usage of Enum all windows. I've never been able to figure out how to get the handle using it.
    Thanks for the reply.

  7. #7
    Hyperactive Member
    Join Date
    Oct 2001
    Location
    The Netherlands
    Posts
    403
    Public Declare Function EnumChildWindows Lib "user32" Alias "EnumChildWindows" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long

    Sub main
    EnumChildWindows windowhwnd, addressof Enummerate, 0
    end sub

    Private funtion Enumerate(hWnd as long, lParam as long)
    'hWnd = hwnd of childs

    'this function will be called as many times as there ar childs.

    'If a child window has created child windows of its own,
    'EnumChildWindows enumerates those windows as well.

    'This function (Enumerate) MUST be placed in a module.
    'Otherwise it won't work

    'If this doesn't work, just say. Next time, I'll test it.

    end function
    Last edited by Xa0z; Nov 5th, 2001 at 11:18 AM.
    There are 10 types of people, those who understand binary and those who don't

    http://merlijn.beyonix.net

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width