473,847 Members | 1,489 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 10783
On May 23, 11:26 am, James Wong <cphk_ms...@nos pam.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.Diagnost ics.ProcessStar tInfo("c:\proce ss.exe")
info.WindowStyl e = ProcessWindowSt yle.Minimized
Dim process As New Process
process.Start(i nfo)

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

"kimiraikko nen" wrote:
On May 23, 11:26 am, James Wong <cphk_ms...@nos pam.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.Diagnost ics.ProcessStar tInfo("c:\proce ss.exe")
info.WindowStyl e = ProcessWindowSt yle.Minimized
Dim process As New Process
process.Start(i nfo)

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...@nos pam.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

"kimiraikko nen" wrote:
On May 23, 11:26 am, James Wong <cphk_ms...@nos pam.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.Diagnost ics.ProcessStar tInfo("c:\proce ss.exe")
info.WindowStyl e = ProcessWindowSt yle.Minimized
Dim process As New Process
process.Start(i nfo)
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.Diagnost ics

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_SHOWMINIMIZE D = 2
SW_SHOWMAXIMIZE D = 3
SW_MAXIMIZE = 3
SW_SHOWNOACTIVA TE = 4
SW_SHOW = 5
SW_MINIMIZE = 6
SW_SHOWMINNOACT IVE = 7
SW_SHOWNA = 8
SW_RESTORE = 9
SW_SHOWDEFAULT = 10
SW_FORCEMINIMIZ E = 11
SW_MAX = 11
End Enum

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

Private Sub minimize()
For Each p As Process In
Process.GetProc essesByName("my console")
ShowWindow(p.Ma inWindowHandle, 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

"kimiraikko nen" wrote:
On May 23, 12:18 pm, James Wong <cphk_ms...@nos pam.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

"kimiraikko nen" wrote:
On May 23, 11:26 am, James Wong <cphk_ms...@nos pam.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.Diagnost ics.ProcessStar tInfo("c:\proce ss.exe")
info.WindowStyl e = ProcessWindowSt yle.Minimized
Dim process As New Process
process.Start(i nfo)
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.Diagnost ics

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_SHOWMINIMIZE D = 2
SW_SHOWMAXIMIZE D = 3
SW_MAXIMIZE = 3
SW_SHOWNOACTIVA TE = 4
SW_SHOW = 5
SW_MINIMIZE = 6
SW_SHOWMINNOACT IVE = 7
SW_SHOWNA = 8
SW_RESTORE = 9
SW_SHOWDEFAULT = 10
SW_FORCEMINIMIZ E = 11
SW_MAX = 11
End Enum

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

Private Sub minimize()
For Each p As Process In
Process.GetProc essesByName("my console")
ShowWindow(p.Ma inWindowHandle, 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...@nos pam.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

"kimiraikko nen" wrote:
On May 23, 12:18 pm, James Wong <cphk_ms...@nos pam.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
"kimiraikko nen" wrote:
On May 23, 11:26 am, James Wong <cphk_ms...@nos pam.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.Diagnost ics.ProcessStar tInfo("c:\proce ss.exe")
info.WindowStyl e = ProcessWindowSt yle.Minimized
Dim process As New Process
process.Start(i nfo)
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.Diagnost ics
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_SHOWMINIMIZE D = 2
* * * * SW_SHOWMAXIMIZE D = 3
* * * * SW_MAXIMIZE = 3
* * * * SW_SHOWNOACTIVA TE = 4
* * * * SW_SHOW = 5
* * * * SW_MINIMIZE = 6
* * * * SW_SHOWMINNOACT IVE = 7
* * * * SW_SHOWNA = 8
* * * * SW_RESTORE = 9
* * * * SW_SHOWDEFAULT = 10
* * * * SW_FORCEMINIMIZ E = 11
* * * * SW_MAX = 11
* * End Enum
* * Sub Main()
* * * * Console.Write(" Press Any Key to minimize window")
* * * * Console.ReadLin e()
* * * * ' Minimize function
* * * * minimize()
* * * * ' See it minimized, then exit
* * * * Console.ReadLin e()
* * End Sub
* * Private Sub minimize()
* * * * For Each p As Process In
Process.GetProc essesByName("my console")
* * * * * * ShowWindow(p.Ma inWindowHandle, 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
6664
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 to the DOS prompt. I just started learning Python a couple of weeks ago, so please bear with me. I have a script that(for now) uses command line arguments then launches a window (Tk). Once I have entered the arguments and the window is...
8
3222
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 working Python scripts to paste into my interactive console and let those run so I don't have to copy line-by-line. Not sure if iPython would meet that criteria or not or even if such a beast exists. It would be helpful for debugging some of my...
3
4325
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 through if executed from a standard application. My question is: How can I make my console mode install application resize it's window or minimize. The code below is what I'm currently trying which doesn't work... the Console BOX stays full...
3
1356
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
287
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 system::io. I have been asked to build the application, open a console window, change to the project's Debug directory, and run the program with a suitable command line, such as Cppfiles sa.
0
1574
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 normal mode without minimize mode. when we running in the console mode our application window is minimized without any issues, when we executed the same in the remote desktop application window is not minimized.
6
28451
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 program, the code block is executing, but no text is written to the command line. What might be causing this?
4
10521
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 doesn't seem to write to the screen in the way I would expect. The output is:
1
2237
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? Carl
0
9734
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10991
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10653
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10347
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7888
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5725
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5915
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4540
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3168
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.