how  to hide the other exe's when it opens up three more exe with it

Posted on 2004-08-23
Last Modified: 2010-05-18

hi all ,

i need to open an exe in inside my form , i was able to do it  using shell or system.dignostics .

The problem i have is that this exe opens up 3 more exe along with it  so when i open the orginal exe inside my form the other 3 exe just opens in the taskbar .

 i  tried to open the other three exe individually in hide mode  even before opening the main exe so that when i open the main exe all other three exe will be in hide mode, but i was able to do just for one  because the other two exe are bind together such that one opens the other one.

please give me some suggestion to tackle this problem

Question by:BeginnerVB_Net
  • 3

Expert Comment

ID: 11878839
u can do allsorts using api like findwindow, to get handle of processes by just their window title, then can sendmessage to them to minimise (some might only minimise to the taskbar, others may not show in taskbar at all)

Accepted Solution

Scoobyed earned 500 total points
ID: 11878867

i've used this to set a window to foreground just from it's title (and have used SendMessage WM_CLOSE to close)

Option Explicit

Private Declare Function PostMessage Lib "User" (ByVal hWnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, lParam As Any) As Integer
Private Declare Sub SetWindowText Lib "User" (ByVal hWnd As Integer, ByVal lpString As String)
Private Declare Function GetActiveWindow Lib "User" () As Integer
Private Declare Function WindowFromDC Lib "user32" (ByVal hdc As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function GetParent Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function GetWindow Lib "user32" (ByVal hWnd As Long, ByVal wCmd As Long) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hWnd As Long, lpdwProcessId As Long) As Long
Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hWnd As Long) As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Any, ByVal lpWindowName As Any) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hWnd As Long) As Long

Const SW_NORMAL = 1

Dim MhWnd As Integer

Const WM_CLOSE = &H10

Private Sub cmdGetExtWindows_Click()

  'Call GetWindowTitle(Me, Me.hwnd)

End Sub

Private Sub cmdSetExtFocus_Click()

  'Call GetWindowFromTitle(Me.txtAppTitle.Text)
  Call LookForWindow(Me.txtAppTitle.Text, True)

End Sub

Function GetWindowTitle(frmWindowFrom As Form, lgShellId As Long) As String
  Dim lgCurrWnd As Long, lgL As Long, lgLength As Long
  Dim stWindowName As String, inX As Integer
  ' Get the hWnd of the first item in the master list
  ' so we can process the task list entries (top-level only)
  lgCurrWnd = GetWindow(frmWindowFrom.hWnd, GW_HWNDFIRST)
  ' Loop while the hWnd returned by GetWindow is valid
  While lgCurrWnd <> 0
    GetWindowThreadProcessId lgCurrWnd, lgL&
    If lgL& = lgShellId Then
      ' Get the length of task name identified by CurrWnd in the list
      lgLength = GetWindowTextLength(lgCurrWnd)
      ' Get task name of the task in the master list
      stWindowName = Space$(lgLength + 1)
      lgLength = GetWindowText(lgCurrWnd, stWindowName, lgLength + 1)
      ' If there is a task name in the list, add the item to the list
      If lgLength > 0 Then
        GetWindowTitle = stWindowName
        Exit Function
      End If
    End If
    ' Get the next task list item in the master list
    lgCurrWnd = GetWindow(lgCurrWnd, GW_HWNDNEXT)
    ' Process Windows events
    inX = DoEvents()
End Function

Function GetWindowFromTitle(ByVal strTitle As String)

  Dim retval As Long
  Dim retval2 As Long
  retval = FindWindow("XLMAIN", 0&)
  If retval <> 0 Then
    retval2 = ShowWindow(retval, SW_NORMAL)
    retval2 = SetForegroundWindow(retval)
    MsgBox strTitle & " is not running"
  End If

End Function

Function LookForWindow(ByVal strAppName As String, ByVal blnActivateWindow As Boolean) As Boolean

  Dim hWnd As Long
  Dim strWinTitle As String
  Dim varRet As Long
  Dim retval2 As Long
  LookForWindow = False
  strAppName = UCase$(strAppName)
  hWnd = FindWindow(0&, 0&)
  Do Until hWnd = 0
    If GetParent(hWnd) = 0 Then
      strWinTitle = Space$(255)
      varRet = GetWindowText(hWnd, strWinTitle, Len(strWinTitle))
      If varRet Then
        strWinTitle = Left$(strWinTitle, varRet)
        strWinTitle = UCase$(strWinTitle)
        If InStr(strWinTitle, strAppName) = 1 Then
          LookForWindow = True
          If blnActivateWindow Then
            retval2 = ShowWindow(hWnd, SW_NORMAL)
            retval2 = SetForegroundWindow(hWnd)
          End If
          Exit Do
        End If
      End If
    End If
    hWnd = GetWindow(hWnd, GW_HWNDNEXT)

End Function

Expert Comment

ID: 11878900

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In a recent question ( here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question