Results 1 to 5 of 5

Thread: to tell when shellexecute has opened

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2001
    Location
    *.*
    Posts
    85

    Question

    I am using a shellexecute loop to open anumber of applications. Is it possible to find out when an application has opened before the loop repeats to open further apps?


    Thx for any advise.


    Everytime

  2. #2
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Try the FinnWIndow API

    Code:
    Dim handle as Long
    handle =  FindWindow("classname","captiontext")
    if handle <> 0 then
    'window opened
    end if
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  3. #3
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Almost forgot
    Code:
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  4. #4
    Megatron
    Guest
    Or use EnumWindows.

    Add to a Module.
    Code:
    Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
    Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
    Declare Function EnumWindows Lib "user32.dll" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
    
    Public Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
        Dim Length As Long
        Dim sName As String
        Dim Temp As String
        Static iCount As Integer
        
        iCount = iCount + 1
        Length = GetWindowTextLength(hwnd) + 1
        
        If Length > 1 Then
          sName = Space(Length)
          GetWindowText hwnd, sName, Length
          Debug.Print Left(sName, Length - 1)
        End If
        
        EnumWindowsProc = 1
    End Function
    Usage
    Code:
    EnumWindows AddressOf EnumWindowsProc, 0
    This will give you a list of all open windows. Then you can just find the window in the list.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Mar 2001
    Location
    *.*
    Posts
    85
    That's great, thx Megatron & Vlatko.

    Megatron,

    The application paths that shellexecute will open are determined by the user at runtime. Hence I will not know what the window text will be.

    So I thought of using the newly opened window's handle (hwnd). When Shellexecute opens the new window can I trap what whnd it is given?


    Ta very much for any help,


    Everytime

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