Click here to Skip to main content
13,353,322 members (49,172 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I have an appliction through it opening/starting another software which always come front of my application and i have to minimize it manualy.

I want when any application/software open through my applicaion should be open in background and minimize always(no reflection).

using code like this but not working.

Any suggestion or something new.


then calling below functions

Public Const SW_MINIMIZE As Integer = 6
Public Function ShowWindow(ByVal hWnd As IntPtr, ByVal nCmdShow As Integer) As Integer
End Function

Public Function FindAndMinimizeWindowByTitle(ByVal Title As String) As Boolean

For Each clsProcess As System.Diagnostics.Process In System.Diagnostics.Process.GetProcesses
  If (clsProcess.ProcessName = Title) Then

     ShowWindow(clsProcess.MainWindowHandle, SW_MINIMIZE)

Return True
End If
Return False

 End Function
Posted 21-Nov-12 19:43pm
Updated 21-Nov-12 19:45pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

The start of Notepad may take some milliseconds. Just wait a little before you call your minimize function.
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

I think,

You can't control other build exe/application accordingly, you need to change in your
application accordingly.
Rate this: bad
Please Sign up or sign in to vote.

Solution 4

I find the following code is often successful for keeping a new process inactive. It does require that the new process respects the initial window state request from the operating system and not all will do this. Notepad is one that does but e.g. VideoLan media player does not.

Private Sub StartProcess()
    Dim psi As New ProcessStartInfo()
    psi.FileName = "notepad.exe"
    psi.UseShellExecute = True
    ' Window Styles not operational unless shell exec is true
    psi.WindowStyle = ProcessWindowStyle.Minimized

    Dim p As New Process()
    p.StartInfo = psi
    ' Reactivate the parent application's form AFTER the new Process has become idle
End Sub

Console processes will raise an exception if WaitForIdleInput is called and I've never found a wholly successful method of keeping those in the background. I had one really annoying application which would activate itself at certain points in it's processing cycle and the only way I could stop that driving me crazy was to run it in a separate desktop via SysInternals Desktops.exe.


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.180111.1 | Last Updated 30 Nov 2012
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100