DevPinoy.org
A Filipino Developers Community
            

Minimize other windows...

Latest post 01-30-2008 3:53 PM by fabs. 13 replies.
  • 01-23-2008 5:53 PM

    • fabs
    • Top 75 Contributor
    • Joined on 12-06-2007
    • Posts 23
    • Points 355

    Minimize other windows...

     Hi guys can somebody help me out???

    Im creating a program in C#.net express 2005 that can minimize other windows... how can i do this??? pls help me out... It will search for a specific window process.. then it will minimized the process if found.. help help help... 

    • Post Points: 20
  • 01-25-2008 2:56 AM In reply to

    • LaTtEX
    • Top 25 Contributor
    • Joined on 02-19-2006
    • Bonifacio Global City
    • Posts 84
    • Points 1,175

    Re: Minimize other windows...

    I don't think you can do that (legally) simply because the Windows API prevents you from accessing the threads of other applications that were not instantiated by you. So unless you're the one who opened that form, you can't minimize it. 

    Jon Limjap tech :: DotNet @ Kape ni LaTtEX personal :: Kape ni LaTtEX our business: I-NAV Travel & Tours
    • Post Points: 35
  • 01-25-2008 6:18 AM In reply to

    Re: Minimize other windows...

    Reply |Contact |Answer

     You can get a handle (hwnd) of each window on the desktop and use P/Invoke to call Win32 api ShowWindow function.

    • Post Points: 5
  • 01-27-2008 8:42 PM In reply to

    • fabs
    • Top 75 Contributor
    • Joined on 12-06-2007
    • Posts 23
    • Points 355

    Re: Minimize other windows...

    LaTtEX:

    I don't think you can do that (legally) simply because the Windows API prevents you from accessing the threads of other applications that were not instantiated by you. So unless you're the one who opened that form, you can't minimize it. 

     

     

    Actually I did it already.. I'll share the codes man.. boybawang is correct.. 

    Filed under: , ,
    • Post Points: 20
  • 01-27-2008 8:52 PM In reply to

    • LaTtEX
    • Top 25 Contributor
    • Joined on 02-19-2006
    • Bonifacio Global City
    • Posts 84
    • Points 1,175

    Re: Minimize other windows...

    Hehehe. P/Invoke. Sabi na eh. Stick out tongue 

    I stand corrected Smile 

    Jon Limjap tech :: DotNet @ Kape ni LaTtEX personal :: Kape ni LaTtEX our business: I-NAV Travel & Tours
    • Post Points: 20
  • 01-27-2008 9:26 PM In reply to

    • fabs
    • Top 75 Contributor
    • Joined on 12-06-2007
    • Posts 23
    • Points 355

    Re: Minimize other windows...

    Reply |Contact |Answer

    [DllImport("user32.dll")]
                    static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);

    /*

    Hide = 0,

    ShowNormal = 1,
    ShowMinimized = 2,
    ShowMaximized = 3,
    Maximize = 3,
    ShowNormalNoActivate = 4,
    Show = 5,
    Minimize = 6,
    ShowMinNoActivate = 7,
    ShowNoActivate = 8,
    Restore = 9,
    ShowDefault = 10,
    ForceMinimized = 11*/ 

     

    then:

    private void HideServices()
            {
                Process[ procs = Process.GetProcessesByName("cmd");
                foreach (Process p in procs)
                {
                    IntPtr pFoundWindow = p.MainWindowHandle;
                    ShowWindow(pFoundWindow, 0);
                }
            }

     

    In this code what i did was hide all the services of the CommandLine... all the cmd processes will be hidden.. 

    Filed under: , ,
    • Post Points: 20
  • 01-27-2008 10:47 PM In reply to

    • modchip
    • Top 10 Contributor
    • Joined on 02-09-2006
    • Ivalice
    • Posts 589
    • Points 8,345

    Re: Minimize other windows...

    Very good fabs! Thanks for sharing! 

    Filed under:
    • Post Points: 20
  • 01-28-2008 1:02 AM In reply to

    • fabs
    • Top 75 Contributor
    • Joined on 12-06-2007
    • Posts 23
    • Points 355

    Re: Minimize other windows...

    No prblem man!!!! I'll share everything na malalaman ko.. hehehe hope this will be usefull.. 

    Filed under: ,
    • Post Points: 20
  • 01-28-2008 11:55 PM In reply to

    • LaTtEX
    • Top 25 Contributor
    • Joined on 02-19-2006
    • Bonifacio Global City
    • Posts 84
    • Points 1,175

    Re: Minimize other windows...

    Question: Why would you want to minimize all other windows? Wouldn't that be quite disrupting, if not outright rude, towards the user?

    Jon Limjap tech :: DotNet @ Kape ni LaTtEX personal :: Kape ni LaTtEX our business: I-NAV Travel & Tours
    • Post Points: 20
  • 01-29-2008 12:47 AM In reply to

    • fabs
    • Top 75 Contributor
    • Joined on 12-06-2007
    • Posts 23
    • Points 355

    Re: Minimize other windows...

     did i say all??? i said other windows... when the program starts i need to start a batch file that pauses at the center of the screen... so i need to hide or minimize it..

    Filed under: ,
    • Post Points: 50
  • 01-29-2008 12:57 PM In reply to

    • LaTtEX
    • Top 25 Contributor
    • Joined on 02-19-2006
    • Bonifacio Global City
    • Posts 84
    • Points 1,175

    Re: Minimize other windows...

     Doesn't this work (setting ProcessStartInfo to Minimized)? Taken from http://msdn2.microsoft.com/en-us/library/system.diagnostics.processstartinfo(VS.71).aspx

            /// <summary>
    /// Uses the ProcessStartInfo class to start new processes, both in a minimized
    /// mode.
    /// </summary>
    public void OpenWithStartInfo()
    {

    ProcessStartInfo startInfo = new ProcessStartInfo("IExplore.exe");
    startInfo.WindowStyle = ProcessWindowStyle.Minimized;

    Process.Start(startInfo);

    startInfo.Arguments = "www.northwindtraders.com";

    Process.Start(startInfo);

    }

     

    Jon Limjap tech :: DotNet @ Kape ni LaTtEX personal :: Kape ni LaTtEX our business: I-NAV Travel & Tours
    • Post Points: 5
  • 01-29-2008 5:17 PM In reply to

    Re: Minimize other windows...

     good job!  :)

    • Post Points: 5
  • 01-29-2008 10:53 PM In reply to

    • LaTtEX
    • Top 25 Contributor
    • Joined on 02-19-2006
    • Bonifacio Global City
    • Posts 84
    • Points 1,175

    Re: Minimize other windows...

    fabs:

     did i say all??? i said other windows... when the program starts i need to start a batch file that pauses at the center of the screen... so i need to hide or minimize it..

     

    So you're the one who started it. You don't need P/Invoke if you started the process. Taken from http://msdn2.microsoft.com/en-us/library/system.diagnostics.processstartinfo(VS.71).aspx:

     

          '/ <summary>
    '/ Uses the ProcessStartInfo class to start new processes, both in a minimized
    '/ mode.
    '/ </summary>
    Public Sub OpenWithStartInfo()

    Dim startInfo As New ProcessStartInfo("IExplore.exe")
    startInfo.WindowStyle = ProcessWindowStyle.Minimized

    Process.Start(startInfo)

    startInfo.Arguments = "www.northwindtraders.com"

    Process.Start(startInfo)
    End Sub 'OpenWithStartInfo

     

    Jon Limjap tech :: DotNet @ Kape ni LaTtEX personal :: Kape ni LaTtEX our business: I-NAV Travel & Tours
    • Post Points: 20
  • 01-30-2008 3:53 PM In reply to

    • fabs
    • Top 75 Contributor
    • Joined on 12-06-2007
    • Posts 23
    • Points 355

    Re: Minimize other windows...

     I need P/Invoke to HIDE some windows that i've started.. well it works now.. thanks for the advices and help man!!!

    Filed under: , ,
    • Post Points: 5
Page 1 of 1 (14 items) | RSS

Copyright DevPinoy 2005-2008
Powered by Community Server (Commercial Edition), by Telligent Systems