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.