(OT) Show desktop from command line?

May 20, 2008
11,400
99
Syracuse, NY, USA
A file such as this SHOWDESK.SFC on the desktop will act like Win 7's show desktop button.
Code:
[Shell]
Command=2
IconFile=explorer.exe,3
[TaskBar]
Command=ToggleDesktop
But I can't "execute" that file by name, with START, or with my SHELLEX (ShellExecute) plugin command. Does anyone know how to "show desktop" from a command line?
 

samintz

Scott Mintz
May 20, 2008
1,503
16
Solon, OH, USA
Windows+D key combination will show the desktop.

Other useful ones I use all the time are:
Win+R - Run... Dialog
Win+L - Lock the workstation

There are a bunch more, but I only use those three.

-Scott
 
May 29, 2008
571
4
Groton, CT
It works under Windows XP Pro SP3, too. And I've created a Take Command tool button for it by filling in the Command field with just the name of the .SCF file.
 
May 20, 2008
11,400
99
Syracuse, NY, USA
Okay, I just tried it in Windows 7 instead of XP, and under Windows 7 it works (i.e. doesn't work) as you describe. Looks like Microsoft broke it!
It's easy enough to do simulating Win-D (I don't have a Win key, code below).
Perhaps Rex will consider adding the Win key to the modifiers recognized by KEYSTACK (in a future version of course).
I could put it in, say, the SYSUTILS plugin. Anyone interested?

Code:
{
    INPUT i[4] = {{INPUT_KEYBOARD,0}, {INPUT_KEYBOARD,0}, {INPUT_KEYBOARD,0}, {INPUT_KEYBOARD,0}};
    i[0].ki.wVk = i[3].ki.wVk = VK_LWIN;
    i[1].ki.wVk = i[2].ki.wVk = 'D';
    i[2].ki.dwFlags = i[3].ki.dwFlags = KEYEVENTF_KEYUP;
    SendInput(4, i, sizeof(INPUT));
    return 0;
}
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,461
88
Albuquerque, NM
prospero.unm.edu
I could put it in, say, the SYSUTILS plugin. Anyone interested?

I've added a MINIMIZEALL to UIStuff:

unm.edu/~cdye/plugins/uistuff.html#minimizeall

It uses the shell's COM interface instead of simulating keystrokes, so it may behave differently from yours....
 
Last edited by a moderator:
Is this a possible solution? I've tried it in XP, and it works;

Minimize all;
Code:
set shelltray=%@winapi[user32,FindWindow,"Shell_TrayWnd",0]
echo %@winapi[user32,PostMessage,%shelltray,273,419]

Minimize undo;
Code:
set shelltray=%@winapi[user32,FindWindow,"Shell_TrayWnd",0]
echo %@winapi[user32,PostMessage,%shelltray,273,416]

Joe
 
May 20, 2008
11,400
99
Syracuse, NY, USA
Is this a possible solution? I've tried it in XP, and it works;

Minimize all;
Code:
set shelltray=%@winapi[user32,FindWindow,"Shell_TrayWnd",0]
echo %@winapi[user32,PostMessage,%shelltray,273,419]

Minimize undo;
Code:
set shelltray=%@winapi[user32,FindWindow,"Shell_TrayWnd",0]
echo %@winapi[user32,PostMessage,%shelltray,273,416]

Joe
Hmmm! It sort of works. After minimizing all that way, clicking Win7's "show desktop" button doesn't bring everything back (especially TCC itself).
 
May 20, 2008
11,400
99
Syracuse, NY, USA
I've added a MINIMIZEALL to UIStuff:
unm.edu/~cdye/plugins/uistuff.html#minimizeall

It uses the shell's COM interface instead of simulating keystrokes, so it may behave differently from yours....
Did you find any quirks? The code I posted, built into an EXE (console or windows) does something very strange. After using it to show the desktop, and either running it again or clicking Win7's button to bring things back, the console in which I gave the command (TCC or CMD) is almost certain ***not*** to have a cursor and although it will accept (some) input, "Enter" does nothing but play the BEEP OK sound.
 
May 20, 2008
11,400
99
Syracuse, NY, USA
I've added a MINIMIZEALL to UIStuff:
unm.edu/~cdye/plugins/uistuff.html#minimizeall

It uses the shell's COM interface instead of simulating keystrokes, so it may behave differently from yours....
One thing different is that it doesn't get all the windows that the Win7 ShowDesktop button (or my simulation of Win-D) does. It misses my PowerPro windows. They may be different in that they have WS_POPUP and WS_EX_TOOLWINDOW.

I tried again with a simulated click (SendInput again) on Win7's ShowDesktop button. That seems to work as well as the button itself. But the button itself is a bit quirky. First, it doesn't always restore windows in the same Z-order (i.e., TCC may be on top of DevStudio before ShowDesktop/Restore and inder it later). Second, when the desktop is restored with a second click, keyboard focus is not restored. And here's a good one ... third ... click Win7's ShowDesktop button **four** times **without moving the mouse in between** (easy with a trackball) ... then press Enter ... here, that causes the StartMenu to open! I've Googled accounts of the ShowDesktop button leaving some windows "always on top" (haven't seen it myself).
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,461
88
Albuquerque, NM
prospero.unm.edu
Did you find any quirks? The code I posted, built into an EXE (console or windows) does something very strange. After using it to show the desktop, and either running it again or clicking Win7's button to bring things back, the console in which I gave the command (TCC or CMD) is almost certain ***not*** to have a cursor and although it will accept (some) input, "Enter" does nothing but play the BEEP OK sound.

I've seen that once or twice while pressing Win-D -- pushing the actual physical keys with my fingers. Perhaps the funky keystroke is confusing the console? Is it possible that Microsoft has never updated the console handler to recognize their very own keys? I have not seen that effect with the shell API approach, but then I haven't tested it much.
 
May 20, 2008
11,400
99
Syracuse, NY, USA
I've seen that once or twice while pressing Win-D -- pushing the actual physical keys with my fingers. Perhaps the funky keystroke is confusing the console? Is it possible that Microsoft has never updated the console handler to recognize their very own keys? I have not seen that effect with the shell API approach, but then I haven't tested it much.
I'd expect that neither the console nor conhost.exe even see a keystroke such as Win-D.
 
Nov 18, 2009
22
0
If you can create a vbscript file, create a file (named "ShowDesktop.vbs") containing:
CreateObject("Shell.Application").ToggleDesktop
and launch it with cscript //B ShowDesktop.vbs

If you have more patience, you can also do a PowerShell command line:
powershell (new-object -comobject "Shell.Application").ToggleDesktop()

But powershell takes a lot longer than cscript to launch.

You could also use the TCC TASKBAR MIN command, though interestingly it only seems to do the first monitor, so it probably doesn't call Shell32.IShellDispatch4.ToggleDesktop.
 
May 20, 2008
11,400
99
Syracuse, NY, USA
Well I really wanted an EXE, so I suppose cscript will work. In yet another attempt, I used the code below, which seems to work just like the Win7 button. Setting the foreground window to the desktop first gets rid of a restored console often not having a cursor and accepting onle some input ... no loss since in my experience, restoring with the ShowDesktop button doesn't give anything input focus.
Code:
    HWND hWnd[3];
    if    (
            (hWnd[0] = FindWindow(L"Shell_TrayWnd", L"")) != NULL
            &&
            (hWnd[1] = FindWindowEx(hWnd[0], NULL, L"TrayNotifyWnd", L"")) != NULL
            &&
            (hWnd[2] = FindWindowEx(hWnd[1], NULL, L"TrayShowDesktopButtonWClass", NULL)) != NULL
        )
    {
        SetForegroundWindow(GetDesktopWindow());
        SendMessage(hWnd[2], WM_LBUTTONDOWN, 0, 0);
        SendMessage(hWnd[2], WM_LBUTTONUP, 0, 0);
    }
 
Mar 1, 2021
1
0
run the following:

explorer.exe shell:::{3080F90D-D7AD-11D9-BD98-0000947B0257}

thats the command to show desktop

theres much more

:D
 
Similar threads
Thread starter Title Forum Replies Date
C show file description? with dir? Support 8
M ANSI is used to show files instead of OEM in version 17 to 19 ! Support 5
T How to? Show the values of batch variables on the TCC screen Support 21
gschizas Take Command (Environment) doesn't show v2 ANSI colors Support 30
w_krieger TCC takes time to show registered to. Support 31
R How to? Not have RT version show on start Support 3
D How to? How to show variables expanded in the log tab Support 3
Alpengreis WAD Command "MSGBOX /?" does not show option /N Support 2
R attribute selection /A:= does not show T Support 3
vefatica LIST and TYPE show UTF8 BOM Support 4
R TC 13 / TCDIALOG for 'dir' / show command Support 2
vefatica IDE window takes 30 seconds to show Support 0
S Can Take Command show TortoiseSvn folder icons? Support 9
S Emailed post did not show up Support 0
E How to? Closing desktop created by DESKTOP command Support 10
Joe Caverly Problem creating and switching to a DESKTOP Support 9
R How to? Win 10 virtual desktops and DESKTOP Support 4
D Tcmd 22.00.42 - annoying desktop refresh Support 47
C TC rearranges my desktop! Support 57
P Desktop customization is ignored by v19 Support 5
S Documentation HELP Nit - Index - Desktop command Support 0
D How to? How do you uncreate a Desktop? Support 1
S DESKTOP - identify current active ? Support 4
vefatica Fixed DESKTOP, START? Support 0
vefatica START /DESKTOP="name with space" ... Support 4
vefatica DESKTOP /N? Support 0
vefatica New desktop and StartUp folder? Support 4
vefatica New desktop, need Explorer PID Support 1
vefatica DESKTOP Support 7
vefatica START /DESKTOP Support 3
vefatica Running TCMD's help on the services desktop Support 0
C starting a shortcut from desktop Support 14
C Desktop Refresh? Support 5
S Desktop Shortcut Hotkey question Support 1
S Desktop hotkey creation using SHORTCUT command Support 4
vefatica Desktop/MyComputer Support 1
Dmitry L. Kobyakov How to? How to remove the record of the old version of the Take Command? Support 5
D Can alias pass parameters to for command? Support 3
samintz How to? Search for %(command) in Help? Support 1
T VIEW only works from command line Support 14
rconn News Take Command / TCC / CMDebug / TCC-RT v28 Released Support 0
T Take Command 28: Lua reports version 5.4.0 (5.4.3 expected) Support 0
Jay Sage WAD Possible Bug With OPTION Command With @FILE Support 5
rconn News Take Command / TCC / CMDebug / TCC-RT 27.01.24 uploaded Support 0
J Take command does not start on Windows 10 Support 3
vefatica `Back quotes` - command line vs. batch file Support 5
Jay Sage WAD Failure of Alias Command with /Z Option Support 14
Phileosophos Is there any way to open the Take Command options dialog from the command line? Support 8
Phileosophos Command-line Editing Shortkeys That Fail Support 6
fpefpe How to? free (internal) command Support 0

Similar threads