1

So I'm programming away in a Command Prompt window and I'm done. I would like to minimize it and move on. My fingers are already on the keyboard, I would like to just enter min or whatever and have the window go away instead of picking up the mouse and clicking on the minimize button. Sort of like entering exit, except I don't want the window to die. Is there a way to program this rather than use keyboard commands? Win7, regular command.exe.

Just figured it out, for those who might care. use Modern::Perl; use Win32::GUI(); my $perlwindow = Win32::GUI::GetPerlWindow(); Win32::GUI::Minimize($perlwindow);

Bill Ruppert
  • 8,956
  • 7
  • 27
  • 44
  • Did you try `Alt`+`Space`, `N`? – Frédéric Hamidi Sep 20 '13 at 12:13
  • Good idea, I was fixated on a command vs. the interface. But I was hoping for something a little easier to type. I would almost as soon as use the mouse! But that will work if nothing else does. – Bill Ruppert Sep 20 '13 at 12:16
  • 3
    If you're on Windows 7, win key + down arrow minimises – Jaloopa Sep 20 '13 at 12:20
  • I changed the question a bit to make it clear that I'm interested in a programmatic way of doing this, not in using the UI. – Bill Ruppert Sep 20 '13 at 12:29
  • Uhm, a console application isn't supposed to mess with its window, if you want full control over your interface you should probably write a GUI application. – Matteo Italia Sep 20 '13 at 12:31
  • 2
    The accepted answer here seems to do what you want: http://stackoverflow.com/questions/775703/letting-a-batch-file-minimize-a-dos-window – Vicky Sep 20 '13 at 12:34
  • 1
    voted to close as duplicate. "off-topic" vote reasons do not apply, to my opinion. this is not off topic. – eis Sep 20 '13 at 13:41

1 Answers1

1

You can use AutoHotkey to add the behavior you desire. You can add a hotstring for "min" that will minimize the current window.

Or, instead of a hotstring (which relies on ahk running) you can make a script that minimizes the current window, compile it into an executable called "min.exe", and put that somewhere where your PATH has access. Then you just run the command. This also removes the need to add validation that min was typed in a shell window rather than, say, Word.

Sample (untested) script which will minimize the window when min + an ending character (space, period, enter) is typed:

::min::
WinMinimize, A
return
Turch
  • 1,546
  • 2
  • 15
  • 31
  • "you can make a script that minimizes the current window" - wasn't that the thing OP asked, is there a way to make such a script? and why would you compile it to an executable? – eis Sep 20 '13 at 13:40
  • By "script" I mean AutoHotkey script, so compiling it is an alternative to having AHK always running on your system. And as for how to write the script, I linked the documentation for getting started. If you think that's not a complete enough answer, I'm adding a sample script. – Turch Sep 20 '13 at 13:43