Results 1 to 3 of 3

Thread: Pausing Application....

  1. #1
    amac
    Guest

    Exclamation Pausing Application....

    Is there anyway that I can call a external application... say... notepad... and have the calling app stop execution until notepad has finished executing???

  2. #2
    Addicted Member
    Join Date
    Feb 2001
    Location
    Upstate NY
    Posts
    210
    i don't know if this would work but...

    Code:
    If FindWindow("Notepad - untitled",vbnullstring) <> 0 then
    'whatever you want to do here
    End If
    That would not run the application or whatever you wanted to do until the Notepad window is present, and i don't think that is the default title of notepad, check it for yourself before you use it.
    < o >

  3. #3
    Matthew Gates
    Guest
    Rh0ads: FindWindow API function is used like: FindWindow(Class, Caption) ( -- FindWindow("SciCalc", "Calculator") )

    But you don't need that API function for this.

    Try this instead:


    VB Code:
    1. Private Declare Function OpenProcess Lib "Kernel32" _
    2. (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, _
    3. ByVal dwProcessId As Long) As Long
    4.  
    5. Private Declare Function GetExitCodeProcess Lib "Kernel32" _
    6. (ByVal hProcess As Long, lpExitCode As Long) As Long
    7.  
    8. Private Declare Sub Sleep Lib "Kernel32" (ByVal dwMilliseconds As _
    9. Long)
    10.  
    11. Const STILL_ACTIVE = &H103
    12. Const PROCESS_QUERY_INFORMATION = &H400
    13.  
    14. 'JobtoDo - Program to run
    15.  
    16.  
    17. Sub ShellWait(ByVal JobToDo As String)
    18.  
    19.          Dim hProcess As Long
    20.          Dim RetVal As Long
    21.          'The next line launches JobToDo as icon,
    22.  
    23.          'captures process ID
    24.          hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, Shell(JobToDo, 1))
    25.  
    26.          Do
    27.  
    28.              'Get the status of the process
    29.              GetExitCodeProcess hProcess, RetVal
    30.  
    31.              'Sleep command recommended as well as DoEvents
    32.              DoEvents: Sleep 100
    33.  
    34.          'Loop while the process is active
    35.          Loop While RetVal = STILL_ACTIVE
    36.          Msgbox "App has been unloaded! Ready to continue..."
    37. End Sub
    38.  
    39.  
    40. [b][u]Usage[/u][/b]
    41.  
    42. Private Sub Command1_Click()
    43.     Call ShellWait("C:\App\App.exe")
    44. End Sub

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