Results 1 to 3 of 3

Thread: Waiting for program to load

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Posts
    11
    I'm running another program using the shell command. Then I call the AppActivate command. But it gives a runtime error saying that the program isn't loaded up yet. The program probably is taking a long time to load. Is there a way to delay or wait until the program is completely loaded?

  2. #2
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    Lightbulb FindWindow API

    It is a good practice to find the specific window before you use the AppActivate function.

    Code:
    Option Explicit
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Long, ByVal lpWindowName As String) As Long
    Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
    Private Const SW_SHOWNORMAL = 1
    
    Dim xhwnd&
        xhwnd = FindWindow(0&, <Your Application Window Title>)
        If xhwnd <> 0 Then
            AppActivate <Your Application Window Title>
            xhwnd = ShowWindow(xhwnd, SW_SHOWNORMAL)
            End
        End If
    End If

  3. #3
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Nitro
    Posts
    633

    FYI

    I just want to add on to one more thing.

    You don't have to provide the entire application's title when you are using "AppActivate" method. You can provide the first 5 letters or less. It just need a close match.

    When you use "FindWindow", you must provide the exact application title. It has to be an exact match or spelling.
    Chemically Formulated As:
    Dr. Nitro

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