CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Guest

    detecting Windows(or its name) in VB and use it in other program

    Is it possible to write a VB program that detects the name of a window and use it to interact with that window(finding captions or clicking buttons)?
    What API functions should I use?


  2. #2
    Join Date
    Apr 1999
    Location
    Brooklyn, NY USA
    Posts
    171

    Re: detecting Windows(or its name) in VB and use it in other program

    Try this:

    Declare Function FindWindow& Lib "user32" Alias "FindWindowA" (byval lpClassName as string, byval lpWindowName as string)



    It will return you a handle of window. As a parameters you can use either Caption of window or Window Class. Window Class of particular window you can find using Spy++ wich comes with VB (with Enterprise edition for sure). Example of finding MS Word:
    lngHandle = FindWindow("OpusApp", vbNullString)
    Example when you know Caption:
    lngHandle = = FindWindow(vbNullString,"MyWindow")
    HTH
    Vlad


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

Featured