Results 1 to 3 of 3

Thread: Watching for programs

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2001
    Posts
    80

    Watching for programs

    I am wanting to be able to look for a program to open.....

    Say i have a program thats running i want it to continue to search until like say word pad opens......

    How can i do this?

  2. #2
    Megatron
    Guest
    This will search for Notepad.
    VB Code:
    1. Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
    2.  
    3. Private Sub Command1_Click()
    4.    
    5.     Dim hWin As Long
    6.    
    7.     hWin = FindWindowEx(0, 0, "Notepad", vbNullString)
    8.    
    9.     Do While hWin = 0
    10.         DoEvents
    11.         hWin = FindWindowEx(0, 0, "Notepad", vbNullString)
    12.     Loop
    13.    
    14.     MsgBox "Notepad is open"
    15.    
    16. End Sub
    The 2nd last argument specifies the classname, and the last argument is the window title. If you "don't care" what the title or class name is, pass vbNullString. In this case I passed vbNullString because the title will vary, whereas the classname is constant.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 2001
    Posts
    80
    Awsome Thanks

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