DESKTOP - identify current active ?

Sep 11, 2012
I liked the new DESKTOP command introduced in Take Command 14.

It would be useful to be able to identify the current active DESKTOP. I would guess that this is possible with clever use of the @WINAPI function - anyone tried that (with success) ??

When searching for good desktop managers, I found Dexpot to be a good one. But also there I have the same/similar issue. The current desktop can be found using the following VB code:

$handle = WinGetHandle("[TITLE:Dexpot - Main Menu; CLASS:ThunderRT6FormDC]")
$ret = DllCall("user32.dll", "int", "SendMessage", "HWND", $handle, "UINT", 2006, "WPARAM", 0, "LPARAM", 0)
MsgBox(0, "Current Desktop", $ret[0])

Guess also this could be achived through through a @WINAPI function.

Sorry, but I am too old for learning C/WinApi :(

Thanks for any suggestion :)

Charles Dye

Super Moderator
Staff member
May 20, 2008
Albuquerque, NM
I'm no expert, but this seems to work for me:

@echo off
set ThreadID=%@winapi[kernel32.dll,GetCurrentThreadId];
set ThreadDesktop=%@winapi[user32.dll,GetThreadDesktop,%ThreadID]
set DesktopName=%@winapi[user32.dll,GetUserObjectInformation,%ThreadDesktop,2,buffer,2048,null]
echo DesktopName = %DesktopName

If you want to hack around with this, be aware that the second argument to the @WINAPI function is case sensitive -- unlike almost everything else in TCC.
Similar threads
Thread starter Title Forum Replies Date
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
vefatica (OT) Show desktop from command line? Support 20
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
Gamegod Fixed TCC identify Chinese problems Support 30
S How to? Identify which monitor is active Support 5
M How to? Identify 64-bit and 32-bit TCC sessions... Support 7
Joe Caverly How to? Get name of current LIBRARY function? Support 4
R How to? Open Take Command at current folder Support 7
R CMDebug, dark theme, current line Support 7
R How to? Obtain current colors Support 2
K copy changing destination current directory Support 1
A Installer /extract: extracts into current directory if target not exists Support 12
scottb How to? ipconfig output in current window Support 4
vefatica TCMD's current directory? Support 4
vefatica Update to current install dir? Support 8
Allen TCC 17 Beta - current functionality? Support 5
M Hotkey-mechanism, for doing something with the current command-line Support 4
Charles Dye IFTP, current directory, open new connection Support 0
A How to? Copy current directory to clipboard Support 9
R How to? Is there a way to see current directories in all drives? Support 11
M How to? A very simple question re. the current line number in a batch file... Support 2
daniel347x How to get Take Command to read in all current system environment variables that CMD.EXE sees? Support 13
D Extracting the current command line, extracting current path Support 4
J Utility to Save/Restore current screen Support 16

Similar threads