473,385 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to minimize command mode window in console program?

Dear all,

I'd like to know if there is any method to minimize command mode window when
a console program is running. In my case, there are several console programs
which run periodically in server. Now, every console program instance will
open a command mode window and they occupy the whole screen. I want to
minimize all of them and maximize it if neccessary by manual. Is it possible
and how to do it? I'm using VB.NET 2005.

Thanks for your attention and kindly advice!

Regards,
James Wong
Jun 27 '08 #1
5 10750
On May 23, 11:26 am, James Wong <cphk_ms...@nospam.nospamwrote:
Dear all,

I'd like to know if there is any method to minimize command mode window when
a console program is running. In my case, there are several console programs
which run periodically in server. Now, every console program instance will
open a command mode window and they occupy the whole screen. I want to
minimize all of them and maximize it if neccessary by manual. Is it possible
and how to do it? I'm using VB.NET 2005.

Thanks for your attention and kindly advice!

Regards,
James Wong
Hi James,
If you want to minimize them on application launch, it's pretty
simple:

' Assuming you have a console app
Dim info As New System.Diagnostics.ProcessStartInfo("c:\process.ex e")
info.WindowStyle = ProcessWindowStyle.Minimized
Dim process As New Process
process.Start(info)

And i suppose you want to minimize *all* of your apps while they're
running, so why don't use just click on "show desktop" on quick launch
bar to minimize all to open spare space on screen?

Thanks,

Onur Güzel
Jun 27 '08 #2
Hi Onur,

Thanks for your reply! But I may not describe my question clearly. The
console programs are either launched by Windows scheduler or manual
double-click in Windows Explorer, but not run by other VB application. My
question is if it is possible to write code to minimize command window within
my console application.

Thanks again for your help!

Regards,
James Wong

"kimiraikkonen" wrote:
On May 23, 11:26 am, James Wong <cphk_ms...@nospam.nospamwrote:
Dear all,

I'd like to know if there is any method to minimize command mode window when
a console program is running. In my case, there are several console programs
which run periodically in server. Now, every console program instance will
open a command mode window and they occupy the whole screen. I want to
minimize all of them and maximize it if neccessary by manual. Is it possible
and how to do it? I'm using VB.NET 2005.

Thanks for your attention and kindly advice!

Regards,
James Wong

Hi James,
If you want to minimize them on application launch, it's pretty
simple:

' Assuming you have a console app
Dim info As New System.Diagnostics.ProcessStartInfo("c:\process.ex e")
info.WindowStyle = ProcessWindowStyle.Minimized
Dim process As New Process
process.Start(info)

And i suppose you want to minimize *all* of your apps while they're
running, so why don't use just click on "show desktop" on quick launch
bar to minimize all to open spare space on screen?

Thanks,

Onur Güzel
Jun 27 '08 #3
On May 23, 12:18 pm, James Wong <cphk_ms...@nospam.nospamwrote:
Hi Onur,

Thanks for your reply! But I may not describe my question clearly. The
console programs are either launched by Windows scheduler or manual
double-click in Windows Explorer, but not run by other VB application. My
question is if it is possible to write code to minimize command window within
my console application.

Thanks again for your help!

Regards,
James Wong

"kimiraikkonen" wrote:
On May 23, 11:26 am, James Wong <cphk_ms...@nospam.nospamwrote:
Dear all,
I'd like to know if there is any method to minimize command mode window when
a console program is running. In my case, there are several console programs
which run periodically in server. Now, every console program instancewill
open a command mode window and they occupy the whole screen. I want to
minimize all of them and maximize it if neccessary by manual. Is it possible
and how to do it? I'm using VB.NET 2005.
Thanks for your attention and kindly advice!
Regards,
James Wong
Hi James,
If you want to minimize them on application launch, it's pretty
simple:
' Assuming you have a console app
Dim info As New System.Diagnostics.ProcessStartInfo("c:\process.ex e")
info.WindowStyle = ProcessWindowStyle.Minimized
Dim process As New Process
process.Start(info)
And i suppose you want to minimize *all* of your apps while they're
running, so why don't use just click on "show desktop" on quick launch
bar to minimize all to open spare space on screen?
Thanks,
Onur Güzel
Hi again,
I tested this and you can minimize a console window using ShowWindow
function API via P/Invoke.

Here is a full simple snippet to minimize a console window:
(Save and compile application as "myconsole")
Imports System.Diagnostics

Module Module1
Private Declare Function ShowWindow Lib "user32.dll" ( _
ByVal hWnd As IntPtr, _
ByVal nCmdShow As SHOW_WINDOW _
) As Boolean

<Flags()_
Private Enum SHOW_WINDOW As Integer
SW_HIDE = 0
SW_SHOWNORMAL = 1
SW_NORMAL = 1
SW_SHOWMINIMIZED = 2
SW_SHOWMAXIMIZED = 3
SW_MAXIMIZE = 3
SW_SHOWNOACTIVATE = 4
SW_SHOW = 5
SW_MINIMIZE = 6
SW_SHOWMINNOACTIVE = 7
SW_SHOWNA = 8
SW_RESTORE = 9
SW_SHOWDEFAULT = 10
SW_FORCEMINIMIZE = 11
SW_MAX = 11
End Enum

Sub Main()
Console.Write("Press Any Key to minimize window")
Console.ReadLine()
' Minimize function
minimize()
' See it minimized, then exit
Console.ReadLine()
End Sub

Private Sub minimize()
For Each p As Process In
Process.GetProcessesByName("myconsole")
ShowWindow(p.MainWindowHandle, SHOW_WINDOW.SW_MINIMIZE)
Next p
End Sub

End Module

.... And you can change "myconsole" which is your orginal console
application's name.(Don't add .exe extension, be careful!) to get
process. Then call the sub named "minimize" (even you can change this
sub name, you know) to invoke ShowWindow function API.
Hope this helps,

Onur Güzel
Jun 27 '08 #4
Hi Onur,

Thanks a lot for your help! What I thought in the past is that I only need
to set some property to minimize the console window. I never imagine that I
need to write code involving API. I'll never make it without your help!

Regards,
James Wong

"kimiraikkonen" wrote:
On May 23, 12:18 pm, James Wong <cphk_ms...@nospam.nospamwrote:
Hi Onur,

Thanks for your reply! But I may not describe my question clearly. The
console programs are either launched by Windows scheduler or manual
double-click in Windows Explorer, but not run by other VB application. My
question is if it is possible to write code to minimize command window within
my console application.

Thanks again for your help!

Regards,
James Wong

"kimiraikkonen" wrote:
On May 23, 11:26 am, James Wong <cphk_ms...@nospam.nospamwrote:
Dear all,
I'd like to know if there is any method to minimize command mode window when
a console program is running. In my case, there are several console programs
which run periodically in server. Now, every console program instance will
open a command mode window and they occupy the whole screen. I want to
minimize all of them and maximize it if neccessary by manual. Is it possible
and how to do it? I'm using VB.NET 2005.
Thanks for your attention and kindly advice!
Regards,
James Wong
Hi James,
If you want to minimize them on application launch, it's pretty
simple:
' Assuming you have a console app
Dim info As New System.Diagnostics.ProcessStartInfo("c:\process.ex e")
info.WindowStyle = ProcessWindowStyle.Minimized
Dim process As New Process
process.Start(info)
And i suppose you want to minimize *all* of your apps while they're
running, so why don't use just click on "show desktop" on quick launch
bar to minimize all to open spare space on screen?
Thanks,
Onur Güzel

Hi again,
I tested this and you can minimize a console window using ShowWindow
function API via P/Invoke.

Here is a full simple snippet to minimize a console window:
(Save and compile application as "myconsole")
Imports System.Diagnostics

Module Module1
Private Declare Function ShowWindow Lib "user32.dll" ( _
ByVal hWnd As IntPtr, _
ByVal nCmdShow As SHOW_WINDOW _
) As Boolean

<Flags()_
Private Enum SHOW_WINDOW As Integer
SW_HIDE = 0
SW_SHOWNORMAL = 1
SW_NORMAL = 1
SW_SHOWMINIMIZED = 2
SW_SHOWMAXIMIZED = 3
SW_MAXIMIZE = 3
SW_SHOWNOACTIVATE = 4
SW_SHOW = 5
SW_MINIMIZE = 6
SW_SHOWMINNOACTIVE = 7
SW_SHOWNA = 8
SW_RESTORE = 9
SW_SHOWDEFAULT = 10
SW_FORCEMINIMIZE = 11
SW_MAX = 11
End Enum

Sub Main()
Console.Write("Press Any Key to minimize window")
Console.ReadLine()
' Minimize function
minimize()
' See it minimized, then exit
Console.ReadLine()
End Sub

Private Sub minimize()
For Each p As Process In
Process.GetProcessesByName("myconsole")
ShowWindow(p.MainWindowHandle, SHOW_WINDOW.SW_MINIMIZE)
Next p
End Sub

End Module

.... And you can change "myconsole" which is your orginal console
application's name.(Don't add .exe extension, be careful!) to get
process. Then call the sub named "minimize" (even you can change this
sub name, you know) to invoke ShowWindow function API.
Hope this helps,

Onur Güzel
Jun 27 '08 #5
On May 23, 2:17*pm, James Wong <cphk_ms...@nospam.nospamwrote:
Hi Onur,

Thanks a lot for your help! *What I thought in the past is that I only need
to set some property to minimize the console window. *I never imagine that I
need to write code involving API. *I'll never make it without your help!

Regards,
James Wong

"kimiraikkonen" wrote:
On May 23, 12:18 pm, James Wong <cphk_ms...@nospam.nospamwrote:
Hi Onur,
Thanks for your reply! *But I may not describe my question clearly. *The
console programs are either launched by Windows scheduler or manual
double-click in Windows Explorer, but not run by other VB application.*My
question is if it is possible to write code to minimize command windowwithin
my console application.
Thanks again for your help!
Regards,
James Wong
"kimiraikkonen" wrote:
On May 23, 11:26 am, James Wong <cphk_ms...@nospam.nospamwrote:
Dear all,
I'd like to know if there is any method to minimize command mode window when
a console program is running. *In my case, there are several console programs
which run periodically in server. *Now, every console program instance will
open a command mode window and they occupy the whole screen. *I want to
minimize all of them and maximize it if neccessary by manual. *Is it possible
and how to do it? *I'm using VB.NET 2005.
Thanks for your attention and kindly advice!
Regards,
James Wong
Hi James,
If you want to minimize them on application launch, it's pretty
simple:
' Assuming you have a console app
Dim info As New System.Diagnostics.ProcessStartInfo("c:\process.ex e")
info.WindowStyle = ProcessWindowStyle.Minimized
Dim process As New Process
process.Start(info)
And i suppose you want to minimize *all* of your apps while they're
running, so why don't use just click on "show desktop" on quick launch
bar to minimize all to open spare space on screen?
Thanks,
Onur Güzel
Hi again,
I tested this and you can minimize a console window using ShowWindow
function API via P/Invoke.
Here is a full simple snippet to minimize a console window:
(Save and compile application as "myconsole")
Imports System.Diagnostics
Module Module1
* * Private Declare Function ShowWindow Lib "user32.dll" ( _
* * ByVal hWnd As IntPtr, _
* * ByVal nCmdShow As SHOW_WINDOW _
* * ) As Boolean
* * <Flags()_
* * Private Enum SHOW_WINDOW As Integer
* * * * SW_HIDE = 0
* * * * SW_SHOWNORMAL = 1
* * * * SW_NORMAL = 1
* * * * SW_SHOWMINIMIZED = 2
* * * * SW_SHOWMAXIMIZED = 3
* * * * SW_MAXIMIZE = 3
* * * * SW_SHOWNOACTIVATE = 4
* * * * SW_SHOW = 5
* * * * SW_MINIMIZE = 6
* * * * SW_SHOWMINNOACTIVE = 7
* * * * SW_SHOWNA = 8
* * * * SW_RESTORE = 9
* * * * SW_SHOWDEFAULT = 10
* * * * SW_FORCEMINIMIZE = 11
* * * * SW_MAX = 11
* * End Enum
* * Sub Main()
* * * * Console.Write("Press Any Key to minimize window")
* * * * Console.ReadLine()
* * * * ' Minimize function
* * * * minimize()
* * * * ' See it minimized, then exit
* * * * Console.ReadLine()
* * End Sub
* * Private Sub minimize()
* * * * For Each p As Process In
Process.GetProcessesByName("myconsole")
* * * * * * ShowWindow(p.MainWindowHandle, SHOW_WINDOW.SW_MINIMIZE)
* * * * Next p
* * End Sub
End Module
.... And you can change "myconsole" which is your orginal console
application's name.(Don't add .exe extension, be careful!) to get
process. Then call the sub named "minimize" (even you can change this
sub name, you know) to invoke ShowWindow function API.
Hope this helps,
Onur Güzel- Hide quoted text -

- Show quoted text -
Thanks for the feedback, if it was a form then minimizing would be
done with a single codeline as you stated by setting windowState
property, but console window is minimized using API.

Glad you solved it :)

Thanks,

Onur Güzel
Jun 27 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Eric Ching | last post by:
Can I run pythonw with a script that takes command line arguments then launches a GUI? I try pythonw myscript.pyw -option arg (etc.) and nothing happens. Nothing, as in I am immediately returned...
8
by: Peter A. Schott | last post by:
Per subject - I realize I can copy/paste a line at a time into an interactive session when I'm trying to debug, but was wondering if there is any tool out there that allows me to copy sections of...
3
by: Mike Oliszewski | last post by:
I am attempting to install the MSDE (SQL 2000) as a part of our application. This requires that you run the MSDE setup.exe program from a Console mode application, it just hangs forever part way...
3
by: TBoon | last post by:
Hi there, A console application (.exe) can be executed at Command Prompt or Windows (double-click). Is there a way to detect whether if it is executed at CP or Windows? regards, Boon
1
by: Allen Maki | last post by:
I would appreciate if someone helps me. I am reading a book called MS visual c++ .net step by step. I am using Visual C++ .net version 2003. I am trying to learn reading from file using...
0
by: =?Utf-8?B?U2VudGhpbCBTdWJyYW1hbmlhbg==?= | last post by:
Our requirement is to run the vb dot net application in minimize mode with system tray icon in the remote machine (remote desktop). When we running in the remote desktop window is showing in...
6
by: joey.powell | last post by:
I have a windows form app in C# in VS2005. In the "program.cs" file, I take some command line arguments and use "Console.WriteLine("fsdfsd") to give feedback to users. When I step through the...
4
by: Peter Nimmo | last post by:
Hi, I am writting a windows application that I want to be able to act as if it where a Console application in certain circumstances, such as error logging. Whilst I have nearly got it, it...
1
by: care02 | last post by:
Dear friends, I have almost completed my first wxPython application. The only thing I need now is to minimize the command window. How is this accomplished on Win32? What about Mac and Linux? ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.