Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

DESKTOP - identify current active ?

Sep
101
1
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])

http://dexpot.de/forum/viewtopic.php?f=12&t=3740

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 :)
 
I'm no expert, but this seems to work for me:

Code:
@echo off
setlocal
 
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
 
endlocal

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

Back
Top