1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

DESKTOP - identify current active ?

Discussion in 'Support' started by Stein Oiestad, Sep 13, 2012.

  1. Stein Oiestad

    Joined:
    Sep 11, 2012
    Messages:
    55
    Likes Received:
    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 :)
     
  2. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,277
    Likes Received:
    38
    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.
     
  3. Stein Oiestad

    Joined:
    Sep 11, 2012
    Messages:
    55
    Likes Received:
    1
    Thanks lot - this worked for me too!

    -stein
     
  4. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,277
    Likes Received:
    38
    Vince's 4Utils plugin has %_DESK %_DESKS and %_IODESK : ftp://lucky.syr.edu/4plugins/4utils.zip

    This is doubtless a faster, easier, and more elegant approach than a bunch of @WINAPI calls in a batch file!
     
  5. Stein Oiestad

    Joined:
    Sep 11, 2012
    Messages:
    55
    Likes Received:
    1
    Thanks again - I grabbed all 64-bits plugins I found: 4console64, 4utils64, sysutils64 - more with 64-bit support ??
     

Share This Page