Making Quick Access Popup TC compatible

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:

Making Quick Access Popup TC compatible

Post by *JnLLnd »

I'm the developer of Folders Popup, a folders launcher used in Windows Explorer and file dialog boxes, but also with various Explorer replacement software and addons. In a few words, when FP is running, you can press the Middle-Mouse button to move to one of your favorite folders. It works under Win XP, 7, 8 and 8.1.

Several TC users asked to add TC support in Folders Popup (FP). I'm now ready to do it but I'll need some help from TC experts here to find the best way to achieve this integration.

Here are the types of interaction I need to develop between FP and TC:

1) Recognize when the active window (or window under the mouse) is a TC lister (required to enable FP popup menu on these windows).

2) Change the folder in the active file list.

3) Open a new TC window in a given folder.

4) Copy the path of the folder in the active file list to the clipboard (to easily add this folder to the popup menu).

5) Open special folders (Desktop, Documents, Pictures, My Computer, Network Neighborhood, Control Panel and Recycle Bin) in the current or in a new TC window.

6) Get a list of all folders opened in all TC file lists.


As much as possible, this would be done by accessing internal TC commands, if available. If not, FP can send keystrokes or mouse clicks to TC. Keystrokes are, of course, more reliable. However, user that change his keyboard layout would break FP integration. Also, commands must work with any localized version of TC and of Windows.

I'll follow-up in the next post with my early findings.

(EDIT 2016-08-14: thread title changed from "Folders Popup" to "Quick Access Popup")
Last edited by JnLLnd on 2016-08-14, 13:35 UTC, edited 1 time in total.
Author of the TC compatible freeware Quick Access Popup
QAP: http://www.quickaccesspopup.com
Other apps: http://code.jeanlalonde.ca
User avatar
JnLLnd
Junior Member
Junior Member
Posts: 53
Joined: 2014-10-01, 12:14 UTC
Location: Montreal, Canada
Contact:

Post by *JnLLnd »

Here are the progress on some points:

1) Recognize when the active window (or window under the mouse) is a TC lister (required to enable FP popup menu on these windows).

SOLVED: window class is "TTOTAL_CMD".


2) Change the folder in the active file list.

Is there a "Go" key? I tried Ctrl-Down (set focus to the command line), type (paste) the folder and {Enter}. But it opens the folder in an Explorer window.


3) Open a new TC window in a given folder.

SOLVED: run the command "C:\totalcmd\TOTALCMD64.EXE c:\temp" (user would have to provide the path to TOTALCMD64.EXE in the FP config).


4) Copy the the path of the folder in the active file list to the clipboard (to easily add this folder to the popup menu).

Ctrl-Y to set focus to the command line and erase its content, Ctrl-P to paste the current path in the command line. Now I need to select the cmd line content (Ctrl-A does not select cmd line content) and copy it to the clipboard.


5) Open special folders (Desktop, Documents, Pictures, My Computer, Network Neighborhood, Control Panel and Recycle Bin) in the current or in a new TC window.

I'm OK with Desktop, Documents, Pictures: I know these paths and just need a solution to 2). The other are more challenging: My Computer, Network Neighborhood, Control Panel and Recycle Bin. For these destinations, I use an internal command with Explorer.


6) Get a list of all folders opened in all TC file lists.

No idea...


Thanks for your input on this!
Author of the TC compatible freeware Quick Access Popup
QAP: http://www.quickaccesspopup.com
Other apps: http://code.jeanlalonde.ca
User avatar
JnLLnd
Junior Member
Junior Member
Posts: 53
Joined: 2014-10-01, 12:14 UTC
Location: Montreal, Canada
Contact:

Post by *JnLLnd »

Forgot to mention that FP is written in AutoHotkey (AKH v1.1).
Author of the TC compatible freeware Quick Access Popup
QAP: http://www.quickaccesspopup.com
Other apps: http://code.jeanlalonde.ca
User avatar
Dalai
Power Member
Power Member
Posts: 9387
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Post by *Dalai »

I strongly recommend to use internal TC commands cm_* to solve some of your issues. That's much better than to "control" TC's GUI, which depends on the user's settings and is subject to change in every new version (TC's cm_* commands are not).

You can get the list of internal commands by
  • typing "cm_CommandBrowser" in TC's command line
  • using the magnifying glass in several places (changing a button of the buttonbar, assigning hotkeys in TC's settings and so on).
3) Open a new TC window in a given folder.

SOLVED: run the command "C:\totalcmd\TOTALCMD64.EXE c:\temp" (user would have to provide the path to TOTALCMD64.EXE in the FP config).
Not quite. The executable of TC 32 bit is TOTALCMD.exe. Or it might even be renamed to explorer.exe because some crappy antivirus software enables its shell extension only in explorer.exe process (e.g. Norton).
2) Change the folder in the active file list.

Is there a "Go" key? I tried Ctrl-Down (set focus to the command line), type (paste) the folder and {Enter}. But it opens the folder in an Explorer window.
Type "CD " before the path. But remember that TC's command line can be hidden via options, or even disabled via RestrictInterface! So that's not as easy as it might seem.
4) Copy the the path of the folder in the active file list to the clipboard (to easily add this folder to the popup menu).
Here you can easily use cm_CopySrcPathToClip. However, it would be better to not modify/overwrite the clipboard's content unless the user knows that this will happen. What I'm trying to say: maybe there's a better way to get the path into your software, without modifying the clipboard (because it's the user's clipboard, not that of any program).

Regards
Dalai
Last edited by Dalai on 2014-10-01, 14:36 UTC, edited 1 time in total.
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6480
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Post by *Horst.Epp »

JnLLnd wrote:Here are the progress on some points:
3) Open a new TC window in a given folder.

SOLVED: run the command "C:\totalcmd\TOTALCMD64.EXE c:\temp" (user would have to provide the path to TOTALCMD64.EXE in the FP config).

Thanks for your input on this!
You need the switch /o as parameter to use the current TC instance
Also the user may want to add /t for tabs.
Better solution is to let the user provide the full TC command line including any parameters and you provide some varaiable to insert for the folder path.
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 Dalai and Horst.Epp for your quick replies. I'll come back to you tonight (Montreal time).
Author of the TC compatible freeware Quick Access Popup
QAP: http://www.quickaccesspopup.com
Other apps: http://code.jeanlalonde.ca
User avatar
Hacker
Moderator
Moderator
Posts: 13064
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

JnLLnd,
2) Change the folder in the active file list.
Help - 4.a)

Code: Select all

totalcmd[64].exe /O /S "/L=c:\path\to\open"
If your program is started by TC, you can use the %COMMANDER_EXE% environment variable.
3) Open a new TC window in a given folder.

Code: Select all

totalcmd[64].exe /N /S "/L=c:\path\to\open"
Opens a new window.

Code: Select all

totalcmd[64].exe /O /S /T "/L=c:\path\to\open"
Opens a new tab.
4) Copy the path of the folder in the active file list to the clipboard (to easily add this folder to the popup menu).

Code: Select all

WinGetText, TCWindowText, ahk_class TTOTAL_CMD
RegExMatch(TCWindowText, "\n(.*)>", TCPath)

HTH
Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
franck8244
Power Member
Power Member
Posts: 703
Joined: 2003-03-06, 17:37 UTC
Location: Geneva...

Post by *franck8244 »

I wrote a TC interaction test tool in ahk v1.1 a few month ago

Implementing all tc -method- (internal tc command / user command / external via copydata)

I organized all in a few ahk classes , if you are interested there's a Link
TC#88260 -
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 all for all these useful insights! This forum works quite well :-)
Hacker wrote:Help - 4.a)
totalcmd[64].exe /O /S "/L=c:\path\to\open"
Yes. This (and the other examples you provide) is exactly what I need. I understand that /S will make sure the /L is applied to the "active" pane (regardless of its left-right side). This will also work on any active tab.
Hacker wrote:WinGetText, TCWindowText, ahk_class TTOTAL_CMD
RegExMatch(TCWindowText, "\n(.*)>", TCPath)
As it is, this does not work (TCPath is empty). Maybe a typo? I'm not a RegEx expert but I made this work by removing the \n. I also stripped the last char.

Code: Select all

RegExMatch(TCWindowText, "(.*)>", TCPath)
StringTrimRight, TCPath, TCPath, 1
MsgBox, !%TCPath%! ; WORKS
I agree that this approach is more reliable than interacting with the Gui.
Dalai wrote:I strongly recommend to use internal TC commands cm_* to solve some of your issues
The list of commands is impressive! Is it possible to invoke these commands from the command line? For example, to open the list if drives in the current pane (not working example): "totalcmd[64].exe /O /S /cm_OpenDrives".
Dalai wrote:
4) Copy the the path of the folder in the active file list to the clipboard (to easily add this folder to the popup menu).
Here you can easily use cm_CopySrcPathToClip.
Interesting. But, here again, how would I invoke this from the command line?
Dalai wrote:maybe there's a better way to get the path into your software, without modifying the clipboard (because it's the user's clipboard, not that of any program
I agree with you. I use the clipboard only if there is no better way to exchange info with a running program and I always backup and restore the user's clipboard when I have to do this.
Horst.Epp wrote:You need the switch /o as parameter to use the current TC instance
Also the user may want to add /t for tabs.
Better solution is to let the user provide the full TC command line including any parameters and you provide some varaiable to insert for the folder path.
Good points. Noted.
franck8244 wrote:I wrote a TC interaction test tool in ahk v1.1 a few month ago

Implementing all tc -method- (internal tc command / user command / external via copydata)

I organized all in a few ahk classes , if you are interested there's a Link
Hummm. Looks like good stuff. I'll dig it. Thanks for sharing.

And, again, thank you all.
Author of the TC compatible freeware Quick Access Popup
QAP: http://www.quickaccesspopup.com
Other apps: http://code.jeanlalonde.ca
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48077
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Forgot to mention that FP is written in AutoHotkey (AKH v1.1).
Please read the following Wiki page for instructions on how to control TC from AutoHotkey:
http://www.ghisler.ch/wiki/index.php/AutoHotkey
Author of Total Commander
https://www.ghisler.com
User avatar
Dalai
Power Member
Power Member
Posts: 9387
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Post by *Dalai »

JnLLnd wrote:
Dalai wrote:I strongly recommend to use internal TC commands cm_* to solve some of your issues
The list of commands is impressive! Is it possible to invoke these commands from the command line? For example, to open the list if drives in the current pane (not working example): "totalcmd[64].exe /O /S /cm_OpenDrives".
You must send the cm_ command to the TC window. I don't know if there is a SendMessage function (or equivalent) in AHK but it works in Delphi and AutoIt. So you kind of have to interact with the GUI but not in a visible way.

AutoIt example:

Code: Select all

#Include <SendMessage.au3>
#Include <WindowsConstants.au3>

global const $CM_COMMANDBROWSER = 2924
global const $TOTALCMDMSG = $WM_USER + 51

$hnd = WinGetHandle("[CLASS:TTOTAL_CMD]")

if $hnd > 0 then
    _SendMessage($hnd, $TOTALCMDMSG , $CM_COMMANDBROWSER, 0)
EndIf
The constants of the cm_ commands can be found in %COMMANDER_PATH%\totalcmd.inc.

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
User avatar
JnLLnd
Junior Member
Junior Member
Posts: 53
Joined: 2014-10-01, 12:14 UTC
Location: Montreal, Canada
Contact:

Post by *JnLLnd »

ghisler(Author) wrote:Please read the following Wiki page for instructions on how to control TC from AutoHotkey:
http://www.ghisler.ch/wiki/index.php/AutoHotkey
Great resource!
Dalai wrote:You must send the cm_ command to the TC window. I don't know if there is a SendMessage function (or equivalent) in AHK but it works in Delphi and AutoIt. So you kind of have to interact with the GUI but not in a visible way.
Yes it does. An example from the wiki mentioned by Ghisler here: http://www.ghisler.ch/wiki/index.php/AutoHotkey:_Send_a_command_to_Total_Commander

Thanks.
Author of the TC compatible freeware Quick Access Popup
QAP: http://www.quickaccesspopup.com
Other apps: http://code.jeanlalonde.ca
User avatar
JnLLnd
Junior Member
Junior Member
Posts: 53
Joined: 2014-10-01, 12:14 UTC
Location: Montreal, Canada
Contact:

Post by *JnLLnd »

So far, so good for items 1-5:

1) Recognize when the active window (or window under the mouse) is a TC lister (required to enable FP popup menu on these windows).

SOLVED: window class is "TTOTAL_CMD".


2) Change the folder in the active file list.

Code: Select all

; look for the TC path in HKEY_CURRENT_USER\Software\Ghisler\Total Commander\InstallDir or HKEY_LOCAL_MACHINE\Software\Ghisler\Total Commander\InstallDir
; test that totalcmd64.exe or totalcmd.exe exists

run, C:\totalcmd\TOTALCMD64.EXE /O /S "/L=c:\temp\" ; /O existing file list, /S source-dest /L=source (active pane) - change folder in the active pane/tab
3) Open a new TC window in a given folder.

Code: Select all

run, C:\totalcmd\TOTALCMD64.EXE /N "/L=c:\temp\" ; /N existing file list, /L= left pane of the new window
4) Copy the the path of the folder in the active file list to the clipboard (to easily add this folder to the popup menu).

Code: Select all

; backup clipboard
cm_CopySrcPathToClip := 2029
SendMessage, 0x433, %cm_CopySrcPathToClip%, , , ahk_class TTOTAL_CMD
; restore clipboard
5) Open special folders (Desktop, Documents, Pictures, My Computer, Network Neighborhood, Control Panel and Recycle Bin) in the current or in a new TC window.

Code: Select all

cm_OpenDesktop := 2121
cm_OpenDrives := 2122
cm_OpenControls := 2123
cm_OpenNetwork := 2125
cm_OpenRecycled := 2127

SendMessage, 0x433, %cm_OpenDesktop%, , , ahk_class TTOTAL_CMD ; 
SendMessage, 0x433, %cm_OpenDrives%, , , ahk_class TTOTAL_CMD ; 
SendMessage, 0x433, %cm_OpenControls%, , , ahk_class TTOTAL_CMD ; 
SendMessage, 0x433, %cm_OpenNetwork%, , , ahk_class TTOTAL_CMD ; 
SendMessage, 0x433, %cm_OpenRecycled%, , , ahk_class TTOTAL_CMD ; 
6) Get a list of all folders opened in all TC file lists.

No solution at this time. WinGetText returns only the path of the active list/tab. Any other idea?

Thank you all for your input.
Author of the TC compatible freeware Quick Access Popup
QAP: http://www.quickaccesspopup.com
Other apps: http://code.jeanlalonde.ca
User avatar
Hacker
Moderator
Moderator
Posts: 13064
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

JnLLnd,
Hacker wrote:WinGetText, TCWindowText, ahk_class TTOTAL_CMD
RegExMatch(TCWindowText, "\n(.*)>", TCPath)
As it is, this does not work (TCPath is empty). Maybe a typo? I'm not a RegEx expert but I made this work by removing the \n. I also stripped the last char.
Ah yes, sorry, you must access the subpattern using TCPath1 as in Send, %TCPath1%.
Or you can use a perhaps more "correct" code using look-behind and look-ahead assertions:

Code: Select all

WinGetText, TCWindowText, ahk_class TTOTAL_CMD
RegExMatch(TCWindowText, "(?<=\n).*(?=>)", TCPath)
Then you can use TCPath as is.
6) Get a list of all folders opened in all TC file lists.

No solution at this time. WinGetText returns only the path of the active list/tab. Any other idea?
Try looking at <AddOn> Update: MultiCopy to TAB v5.8/25 Sep 2010. No idea if the source is included, though.

HTH
Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
JnLLnd
Junior Member
Junior Member
Posts: 53
Joined: 2014-10-01, 12:14 UTC
Location: Montreal, Canada
Contact:

Post by *JnLLnd »

Hacker wrote:Try looking at <AddOn> Update: MultiCopy to TAB v5.8/25 Sep 2010. No idea if the source is included, though.
I found no source file. But thanks for the info.
Author of the TC compatible freeware Quick Access Popup
QAP: http://www.quickaccesspopup.com
Other apps: http://code.jeanlalonde.ca
Post Reply