VitrualPanel, TC Hotlist and Quick Access Popup

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: white, Hacker, petermad, Stefan2

User avatar
JnLLnd
Junior Member
Junior Member
Posts: 53
Joined: 2014-10-01, 12:14 UTC
Location: Montreal, Canada
Contact:

VitrualPanel, TC Hotlist and Quick Access Popup

Post by *JnLLnd »

@MVV (author of VirtualPanel)

I'm the author of Quick Access Popup. As part of its integration with TC, QAP reads the TC Hotlist ([DirMenu] section in ini file) to build a popup menu with it. A QAP and TC user took to my attention that Hotlist entries using VP could not be launched from QAP menu as could be regular directories in the Hotlist.

See this thread:
http://www.quickaccesspopup.com/how-do-i-enable-total-commander-support-in-quick-access-popup/#comment-11791

I lack time actually for installing and learning VP. Your help would be appreciated. Two questions:

1) Is there a safe way to recognize VP entries in TC Hotlist so than I can exclude them until I can build support for this in QAP?

2) For longer term, is there a way to call an entry like cmd39=cd \\\VP\project1 from an external program and get the actual path/command to show its content in TC?

FYI, QAP is sending commands to TC using AutoHotkey "SendMessage" commands (for example: SendMessage, 0x433, %g_strFullLocation%, , , ahk_class TTOTAL_CMD.

Thanks for your help,

Jean
Author of the TC compatible freeware Quick Access Popup
QAP: http://www.quickaccesspopup.com
Other apps: http://code.jeanlalonde.ca
Skif_off
Member
Member
Posts: 132
Joined: 2013-09-30, 13:13 UTC

Post by *Skif_off »

Sorry, I am not MVV (my hero!), but fifty cents burn pocket :)

1) "\VirtualPanel" is default name, but this name is optional (as for other wfx-plugins): you must find him for current TC copy and find "\\\Name\" in your string. For example on AutoIt (pieces of my script):

Code: Select all

#NoTrayIcon

Opt('WinWaitDelay', 100)

Local $your_path = '\\\VP\project1'
Local $aTCPlugName = _TCPlugSearch('VirtualPanel.wfx', 'FileSystemPlugins') ;First plugin copy
If IsArray($aTCPlugName) Then
    If StringInStr($your_path, '\\\' & $aTCPlugName[0]) & '\') Then
        MsgBox(64 + 4096, 'AddProfileToVirtualPanel.au3', '"' & $your_path & '" is VirtualPanel path!')
    Else
        MsgBox(16 + 4096, 'AddProfileToVirtualPanel.au3', '"' & $your_path & '" is not VirtualPanel path!')
    EndIf
Else
    MsgBox(48 + 4096, 'AddProfileToVirtualPanel.au3', 'Plugin VirtualPanel not found!')
EndIf

Func _TCPlugSearch($name, $type)
    ;$name = w?x-name
    ;$type = 'PackerPlugins' or 'FileSystemPlugins' or 'ListerPlugins' or 'ContentPlugins'
    ;Return array: [name/ext/index, w?x path]
    Local $T, $sConfig, $aTCPs, $i, $aRet[2], $COMMANDER_INI = EnvGet('COMMANDER_INI')
    $T = IniRead($COMMANDER_INI, $type, 'RedirectSection', 'def')
    Switch $T
        Case 0, 'def'
            $sConfig = $COMMANDER_INI
        Case 1
            $sConfig = IniRead($COMMANDER_INI, 'Configuration', 'AlternateUserIni', 'def')
            If $sConfig = 'def' Then Return 0
            $sConfig = _WinAPI_ExpandEnvironmentStrings($sConfig)
            If Not FileExists($sConfig) Then
                $sConfig = StringRegExpReplace($COMMANDER_INI, '\\[^\\]+$', '\\' & $T)
                If Not FileExists($sConfig) Then
                    Return 0
                EndIf
            EndIf
        Case Else
            $sConfig = _WinAPI_ExpandEnvironmentStrings($T)
            If Not FileExists($sConfig) Then
                $sConfig = StringRegExpReplace($COMMANDER_INI, '\\[^\\]+$', '\\' & $T)
                If Not FileExists($sConfig) Then
                    Return 0
                EndIf
            EndIf
    EndSwitch
    $aTCPs = IniReadSection($sConfig, $type)
    For $i = 1 To $aTCPs[0][0]
        If StringInStr($aTCPs[$i][1], $name) Then
            $aRet[0] = $aTCPs[$i][0]
            If $type = 'PackerPlugins' Then
                $aRet[1] = StringRegExpReplace($aTCPs[$i][1], '^\d+,', '', 1)
            Else
                $aRet[1] = $aTCPs[$i][1]
            EndIf
            Return $aRet
        Else
            ContinueLoop
        EndIf
    Next
    Return 0
EndFunc ;==>_TCPlugSearch

Func _WinAPI_ExpandEnvironmentStrings($sString)
    Local $aResult = DllCall("kernel32.dll", "dword", "ExpandEnvironmentStringsW", "wstr", $sString, "wstr", "", "dword", 4096)
    If @error Then Return SetError(@error, @extended, "")
    Return $aResult[2]
EndFunc   ;==>_WinAPI_ExpandEnvironmentStrings
_TCPlugSearch() is my universal function for all plugins +support RedirectSection & AlternateUserIni, but you can make it shorter because QAP uses DirMenu and already "knows" current TC configuration file.

2) If you want to open this path then you can use WM_COPYDATA:

Code: Select all

Global Const $WM_COPYDATA = 0x004A

;ТС window handle (for WM_COPYDATA)
Local $hTC = WinGetHandle('[CLASS:TTOTAL_CMD]')
If @error Then
    MsgBox(48 + 4096, 'AddProfileToVirtualPanel.au3', 'TC not found!')
    Exit
EndIf
;Script window handle (for WM_COPYDATA too)
AutoItWinSetTitle(@ScriptName)
$hWndPar = WinGetHandle(@ScriptName)

;cd \\\VP\project1, current tab
_TC_cd_command(__CheckANSItoUTF8($your_path), '', 'S')

; ANSI >> UTF-8 (if need)
Func __CheckANSItoUTF8($sStr)
    Local $sStrTemp, $BOM = Chr(239) & Chr(187) & Chr(191) ; \xEF \xBB \xBF
    $sStrTemp = BinaryToString(StringToBinary($sStr, 1), 1)
    If Not ($sStr == $sStrTemp) Then
        $sStr = BinaryToString(StringToBinary($sStr, 4))
        Return $BOM & $sStr
    Else
        Return $sStr
    EndIf
EndFunc   ;==>__CheckANSItoUTF8

Func _TC_cd_command($l, $r, $sFlag = "")
    Local $sCommand = $l & @CR & $r & ChrW(0) & $sFlag
    Local $pCDcom = DllStructCreate("char[" & StringLen($sCommand)+ 1 & "]")
    Local $pCopyData = DllStructCreate("ulong_ptr;dword;ptr")
    DllStructSetData($pCDcom, 1, $sCommand)
    DllStructSetData($pCopyData, 1, Asc("C") + 256 * Asc("D"))
    DllStructSetData($pCopyData, 2, DllStructGetSize($pCDcom))
    DllStructSetData($pCopyData, 3, DllStructGetPtr($pCDcom))
    DllCall("user32.dll", "int", "SendMessageW", "hwnd", $hTC, "int", $WM_COPYDATA, "wparam", $hWndPar, "lparam", DllStructGetPtr($pCopyData))
EndFunc   ;==>_TC_cd_command
Or you can try

Code: Select all

"%COMMANDER_PATH% /O /S /L="\\\VP\project1"
without "cd " and WM_COPYDATA (I have not tried).
Last edited by Skif_off on 2016-09-18, 14:46 UTC, edited 1 time in total.
User avatar
JnLLnd
Junior Member
Junior Member
Posts: 53
Joined: 2014-10-01, 12:14 UTC
Location: Montreal, Canada
Contact:

Post by *JnLLnd »

Thank you Skif_off for all this info.

Could you send me a sample of the section [FileSystemPlugins] of the ini file when VP is installed? It will help.
Author of the TC compatible freeware Quick Access Popup
QAP: http://www.quickaccesspopup.com
Other apps: http://code.jeanlalonde.ca
User avatar
nsp
Power Member
Power Member
Posts: 1805
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Post by *nsp »

JnLLnd wrote:Thank you Skif_off for all this info.

Could you send me a sample of the section [FileSystemPlugins] of the ini file when VP is installed? It will help.
The FileSystemPlugin section can be found in the wincmd.ini but it can also be "redirected" to other file. (You can read the redirections from wincmd.ini).
the safiest way to get wich wincmd ini file is used, is to query TC using CopyDATA messaging.
But the easiest way would be to just add a parameter in your application to "detect VirtualPanel prefixe/s".
normal mesages to change folder should work (adding "") at the end to go "inside" the folder
Skif_off
Member
Member
Posts: 132
Joined: 2013-09-30, 13:13 UTC

Post by *Skif_off »

2JnLLnd
I use default name without redirections:

Code: Select all

[FileSystemPlugins]
VirtualPanel=%COMMANDER_PATH%\Plugins\wfx\VirtualPanel\VirtualPanel.wfx
2nsp
nsp wrote:the safiest way to get wich wincmd ini file is used, is to query TC using CopyDATA messaging.
How? I did not find: history852.txt, history900.txt.
User avatar
nsp
Power Member
Power Member
Posts: 1805
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Post by *nsp »

2nsp
nsp wrote:the safiest way to get wich wincmd ini file is used, is to query TC using CopyDATA messaging.
How? I did not find: history852.txt, history900.txt.
I guessed that all the requests about TC context was covered by the messaging system. I was wrong about %COMMANDER_INI% :oops: .

If you can be called by TC the %COMMANDER_INI% var contain the current ini file path. Reading registry can help but does not cover all the situations.

With FileSystem plugins, you need to add a final "" if you want the path to be considered as a folder destination.
User avatar
JnLLnd
Junior Member
Junior Member
Posts: 53
Joined: 2014-10-01, 12:14 UTC
Location: Montreal, Canada
Contact:

Post by *JnLLnd »

Skif_off wrote:2JnLLnd
I use default name without redirections:

Code: Select all

[FileSystemPlugins]
VirtualPanel=%COMMANDER_PATH%\Plugins\wfx\VirtualPanel\VirtualPanel.wfx
And could you show me what are the entries for VirtualPanel destinations in [DirMenu] (Hotlist) section of WinCdd.ini?
Author of the TC compatible freeware Quick Access Popup
QAP: http://www.quickaccesspopup.com
Other apps: http://code.jeanlalonde.ca
Skif_off
Member
Member
Posts: 132
Joined: 2013-09-30, 13:13 UTC

Post by *Skif_off »

2JnLLnd
Click "*" >> "Add current dir":

Code: Select all

menu72=Test
cmd72=cd \\\VirtualPanel\Test
I am sorry, I made a mistake:
Skif_off wrote:2) If you want to open this path then you can use WM_COPYDATA, but you must load plugin first (open "\\\VP"):
This is wrong and unnecessary for you: I use calls VPBatch.exe to add new folders, but VPBatch.exe not works if plugin VirtualPanel not loaded. I am sorry :( I corrected my post ($hWndPar too).

And about "", what nsp wrote:
06.07.16 Release Total Commander 9.0 beta 4 (32/64)
03.07.16 Fixed: Search in separate process, go to file: not working with FS plugins, tried to open file as directory. Change: Plugin path received via WM_COPYDATA must end with \ if it's not a file (32/64)
User avatar
JnLLnd
Junior Member
Junior Member
Posts: 53
Joined: 2014-10-01, 12:14 UTC
Location: Montreal, Canada
Contact:

Post by *JnLLnd »

Skif_off wrote:2JnLLnd
Click "*" >> "Add current dir":

Code: Select all

menu72=Test
cmd72=cd \\\VirtualPanel\Test
Thanks Skif_off. This helps. I got the whole picture with it.

If I summarize, I have to check the[FileSystemPlugins] section of WinCdm.ini for a variable name (var_name) that would be used in the [DirMenu] section in the following format:

Code: Select all

cmd#=cd \\\var_name\etc.
Once found, it the value for this variable in [FileSystemPlugins] contains "VirtualPanel.wfx" this is a VirtualPlaner location.

Thanks all!
Author of the TC compatible freeware Quick Access Popup
QAP: http://www.quickaccesspopup.com
Other apps: http://code.jeanlalonde.ca
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

I don't understand why do you search for Virtual Panel only entries because all FS plugins work in a similar way, and paths for all of them start with \\\, so this prefix is a very good signature of FS plugin path.
And, as it was mentioned, you should use WM_COPYDATA message to tell TC to change current directory. Or you can use this slow but simple way: TOTALCMD.exe /S /O /L="path". Both ways allow opening new folder in new tab.
User avatar
JnLLnd
Junior Member
Junior Member
Posts: 53
Joined: 2014-10-01, 12:14 UTC
Location: Montreal, Canada
Contact:

Post by *JnLLnd »

Hi MVV,

Thinking about this on my bike this morning, it was exactly my next question: is the triple-backslash a convention for all file system plugins. Got it. Thanks.

I'm using TOTALCMD.EXE with a combination of switches to open in the current tab, or in a new tab (and on which side), or in a complete new instance of TC. I could switch to WM_COPYDATA but if this is only for speed improvement, this is not a big gain in this situation.

However, if using WM_COPYDATA would allow to change to a VP folder this would be an interesting benefit. Would it?
Author of the TC compatible freeware Quick Access Popup
QAP: http://www.quickaccesspopup.com
Other apps: http://code.jeanlalonde.ca
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Both TOTALCMD.EXE with /O argument and WM_COPYDATA allow switching to any FS plugin folder w/o problems, just tried that and it works:

Code: Select all

TOTALCMD.EXE /S /O /L="\\\Virtual Panel\Pictures\"
In fact, you don't need to bother what kind of path you have, TC should do all job for you.
User avatar
JnLLnd
Junior Member
Junior Member
Posts: 53
Joined: 2014-10-01, 12:14 UTC
Location: Montreal, Canada
Contact:

Post by *JnLLnd »

MVV wrote:Both TOTALCMD.EXE with /O argument and WM_COPYDATA allow switching to any FS plugin folder w/o problems
OK. I'll return to my user who reported an issue with this. The issue may not be related to plugins. Thanks for checking.
Author of the TC compatible freeware Quick Access Popup
QAP: http://www.quickaccesspopup.com
Other apps: http://code.jeanlalonde.ca
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

You should keep in mind that some plugins don't support switching to inner directory, but in such case hotlist should work in the same way as remote directory switch command.
User avatar
JnLLnd
Junior Member
Junior Member
Posts: 53
Joined: 2014-10-01, 12:14 UTC
Location: Montreal, Canada
Contact:

Post by *JnLLnd »

MVV wrote:You should keep in mind that some plugins don't support switching to inner directory, but in such case hotlist should work in the same way as remote directory switch command.
OK. Thanks.

After more input from QAP+TC user, I found that the cause of this issue was not what I was thinking. This is because QAP checks if a favorite folder exists before opening it. Because it checks this outside TC, it cannot find the virtual folder and it does not even try to open it (if it was trying, it could open it with TC).

In the next release, QAP will stop checking if folder exists if:
1) it is launched from TC Directory Hotlist and
2) the location starts with “\\\”.

No need for additional coding to support TC file system plugins like VirtualPanel.
Author of the TC compatible freeware Quick Access Popup
QAP: http://www.quickaccesspopup.com
Other apps: http://code.jeanlalonde.ca
Post Reply