copy path to clipboard - wine
Moderators: Hacker, petermad, Stefan2, white
copy path to clipboard - wine
I use the "copy path to clipboard" a lot with windows.
It also works under wine, but copies it in windows format.
Does anyone know how to make it copy in Linux format (for example replace Z:\usr with /usr).
I tried the Lst2Clip.exe addon, it worked in windows but unfortunately not under wine.
It also works under wine, but copies it in windows format.
Does anyone know how to make it copy in Linux format (for example replace Z:\usr with /usr).
I tried the Lst2Clip.exe addon, it worked in windows but unfortunately not under wine.
- Balderstrom
- Power Member
- Posts: 2148
- Joined: 2005-10-11, 10:10 UTC
Doesn't AHK work under wine?
If not there is IronAHK which uses Mono, I've no experience with it personally.
But if either of the above:
Make a button that calls the AHK script.
---> Command: Location/of/AutoHotkey.exe "Location/of/Script/TC_CopySrcPathToClip.ahk"
You could also probably use some linux tools in conjunction with TCMC.exe, eg
Command: TCMC.exe 50 CMcm_CopySrcPathToClip EMem_ConvertToLinuxSlash
Define, em_ConvertToLinuxSlash as something along the lines of
If not there is IronAHK which uses Mono, I've no experience with it personally.
But if either of the above:
Code: Select all
;; TC_CopySrcPathToClip.ahk
PostMessage, 0x433, 2029, 0x0,, A ; cm_CopySrcPathToClip
ClipWait
StringReplace, ClipBoard, ClipBoard, \, /, All
;Comment the next line with a semi-colon if working as expected.
MsgBox, clip: %ClipBoard%
---> Command: Location/of/AutoHotkey.exe "Location/of/Script/TC_CopySrcPathToClip.ahk"
You could also probably use some linux tools in conjunction with TCMC.exe, eg
Command: TCMC.exe 50 CMcm_CopySrcPathToClip EMem_ConvertToLinuxSlash
Define, em_ConvertToLinuxSlash as something along the lines of
Maybe Karlchen can help with the specifics, I don't have linux or cygwin installed these days, but the above commands work using a google-code compile of GNU's UnxUtils (in CMD.exe).pclip | sed s/\\/\//g | gclip
Hi, Balderstrom.
Your help is appreciated as much as your AHK expertise.
Until now I have never tried running AHK on Wine.
The reason is pretty trivial:
My aim is not running as many Windows applications as possible on Ubuntu with the help of Wine, but instead finding genuine Linux equivalents for the Windows applications which I use on Windows.
Sad, but true, there is no appropriate genuine Linux replacement for Total Commander.
This is why I run into the problem that T.C. can copy the (long) filename / pathname which I need into the clipboard, but it does so in Windows format, yet I need Linux format.
As a consequence, it would be really helpful to have the functionality which Lefteous's tiny programme lst2clip offers on Windows platforms, e.g.
Realistically, I do not expect Lefteous to sit down after 8 years and try to find out why lst2clip does not work on Wine. And I do not expect the Wine guys to find out why Wine does not like lst2clip. But maybe Christian can be persuaded to extend the list of existing cm_Copy_<Something>_ToClip commands a bit in a future T.C. version.
Guess rather than undigging a dead thread from its grave, I should have posted a feature request ...
---
About the second approach:
Hm, this might put me on the right track. Though the pitfall is that launching genuine Linux commands like sed is not done easily from inside a programme which itself runs under Wine (Total Commander).
Reads like this could be a task for a long and cold Sunday afternoon.
Kind regards,
Karl
Your help is appreciated as much as your AHK expertise.

Until now I have never tried running AHK on Wine.
The reason is pretty trivial:
My aim is not running as many Windows applications as possible on Ubuntu with the help of Wine, but instead finding genuine Linux equivalents for the Windows applications which I use on Windows.
Sad, but true, there is no appropriate genuine Linux replacement for Total Commander.
This is why I run into the problem that T.C. can copy the (long) filename / pathname which I need into the clipboard, but it does so in Windows format, yet I need Linux format.
As a consequence, it would be really helpful to have the functionality which Lefteous's tiny programme lst2clip offers on Windows platforms, e.g.
- replacing backslashes by forward slashes in pathnames
- removing unwanted prefixes like the Wine drive letter Z: from the pathnames
Realistically, I do not expect Lefteous to sit down after 8 years and try to find out why lst2clip does not work on Wine. And I do not expect the Wine guys to find out why Wine does not like lst2clip. But maybe Christian can be persuaded to extend the list of existing cm_Copy_<Something>_ToClip commands a bit in a future T.C. version.
Guess rather than undigging a dead thread from its grave, I should have posted a feature request ...
---
About the second approach:
Hm, this might put me on the right track. Though the pitfall is that launching genuine Linux commands like sed is not done easily from inside a programme which itself runs under Wine (Total Commander).
Reads like this could be a task for a long and cold Sunday afternoon.

Kind regards,
Karl
<update, just to give a hint I am still working on it>
After spending (too much) time on trying out a number of things and reading quite a number of articles on X Windows clipboard behaviour, I am pretty sure that the main problem is as explained by the following example:
Lst2clip.exe stuffs modified pathnames into the clipboard for another programme to use them and then exits. The very same moment it exits its content is removed from the clipboard.
</update>
After spending (too much) time on trying out a number of things and reading quite a number of articles on X Windows clipboard behaviour, I am pretty sure that the main problem is as explained by the following example:
- Under Wine you launch T.C.
- Inside T.C. you launch Notepad2.
- Inside Notepad2 you write some text, mark it and stuff it into the clipboard by pressing Ctrl-C.
- You close Notepad2.
- You activate the T.C. commandline e.g.
- You press Ctrl-V in order to paste the content of the clipboard into commandline. But, surprise, surprise, nothing gets pasted. The clipboard content is gone.
- Explanation: The moment Notepad2 was closed, the text which had be stuffed into the clipboard by Notepad2, was removed from the clipboard.
Lst2clip.exe stuffs modified pathnames into the clipboard for another programme to use them and then exits. The very same moment it exits its content is removed from the clipboard.
</update>
- Balderstrom
- Power Member
- Posts: 2148
- Joined: 2005-10-11, 10:10 UTC
Shouldn't the pclip/gclip option work though? Although I don't know if you would need to use the windows compiled ones or the native linux commands.
Balderstrom wrote:You could also probably use some linux tools in conjunction with TCMC.exe, eg
Command: TCMC.exe 50 CMcm_CopySrcPathToClip EMem_ConvertToLinuxSlash
Define, em_ConvertToLinuxSlash as something along the lines ofpclip | sed s/\\/\//g | gclip
- Balderstrom
- Power Member
- Posts: 2148
- Joined: 2005-10-11, 10:10 UTC
Here's the compilation of UnxUtils @ googlecode I use in windows.
The google-code version contains a few files missing from the listing on sourceforge. As well many of the binaries have been updated.
The google-code version contains a few files missing from the listing on sourceforge. As well many of the binaries have been updated.
Hello, Balderstrom.
<thumb up>
You are the man! Your suggestion based on TCMC and UnxUtils (posts: [1] [2] [3]) is the absolutely right approach.
</thumb up>
It works here, hm, almost, not quite out of the box, but with a small number of modifications.
Solution: Instead of using the Windows programme gclip.exe, the original Linux xclip will be used.
OK, skipping all failed attempts, this is what works here perfectly:
Cheers,
Karl
--
Corrected Saturday 12-Feb-2001 21:15 MET:
Definition of the T.C. command em_ConvertToLinuxSlash: Replaced the chain of piped sed commands by one call to sed which processes 3 (corrected) substitution expressions.
Old: param=/c pclip| sed s#\\#/#g | sed s#C:#~/.wine/drive_c#g | sed s#Z:##g | /usr/bin/xclip -i -sel clip
New: param=/c pclip| sed -e "s#\\#/#g" -e "s#^C:#~/.wine/drive_c#g" -e "s#^Z:##g" | /usr/bin/xclip -i -sel clip
<thumb up>
You are the man! Your suggestion based on TCMC and UnxUtils (posts: [1] [2] [3]) is the absolutely right approach.
</thumb up>
It works here, hm, almost, not quite out of the box, but with a small number of modifications.

2 third of this command do what they should:pclip | sed s/\\/\//g | gclip
But gclip either fails to store the input it gets from sed into the clipboard. Or we are back to the old problem: as soon as a Windows programme exits, Wine will clear its clipboard.pclip | sed s/\\/\//g
Solution: Instead of using the Windows programme gclip.exe, the original Linux xclip will be used.
OK, skipping all failed attempts, this is what works here perfectly:
- Total Commander button definition: TOTALCMD#BAR#DATA
%COMMANDER_PATH%\Addons\TCMC.exe 50 CMcm_CopyFullNamesToClip EMem_ConvertToLinuxSlash
%COMMANDER_PATH%\WCMICONS.DLL,59
Copy Fullname As LinuxPath
%COMMANDER_PATH%\Addons
-1 - Definition of user command em_ConvertToLinuxSlash:
(The chain of sed commands has been fine tuned to match my personal requirements.)[em_ConvertToLinuxSlash]
button=WCMICONS.DLL,59
cmd=start cmd.exe
param=/c pclip| sed -e "s#\\#/#g" -e "s#^C:#~/.wine/drive_c#g" -e "s#^Z:##g" | /usr/bin/xclip -i -sel clip
menu=slash
path=%COMMANDER_PATH%\Addons - Used addons / external programmes:
+ TCMC.exe
+ pclip.exe, sed.exe from the UnxUtils
+ xclip from the Ubuntu distribution - Environment:
+ Ubuntu 10.04 Lucid Lynx, 32-bit
+ Wine 1.2.2
+ Total Commander 7.56a - Result:
The commandline which is launched by the T.C. button will remove the drive letters and replace backslashes by forward slashes. And most important of all: the resulting strings will be stored inside the clipboard and can be retrieved from the clipboard.

Cheers,
Karl
--
Corrected Saturday 12-Feb-2001 21:15 MET:
Definition of the T.C. command em_ConvertToLinuxSlash: Replaced the chain of piped sed commands by one call to sed which processes 3 (corrected) substitution expressions.
Old: param=/c pclip| sed s#\\#/#g | sed s#C:#~/.wine/drive_c#g | sed s#Z:##g | /usr/bin/xclip -i -sel clip
New: param=/c pclip| sed -e "s#\\#/#g" -e "s#^C:#~/.wine/drive_c#g" -e "s#^Z:##g" | /usr/bin/xclip -i -sel clip
Last edited by karlchen on 2011-02-12, 20:19 UTC, edited 1 time in total.
- Balderstrom
- Power Member
- Posts: 2148
- Joined: 2005-10-11, 10:10 UTC
Two more usage examples of TCMC, pclip, sed and xclip
For those who might be interested:
Here are two more usage examples of TCMC, pclip, sed and xclip. They work fine here. They may, however, need a little bit of tweaking on other systems. No warranty given they will work out of the box for everybody.
Karl
Here are two more usage examples of TCMC, pclip, sed and xclip. They work fine here. They may, however, need a little bit of tweaking on other systems. No warranty given they will work out of the box for everybody.

- Name: Copy SSH Path As Linux Path
Purpose: Convert a fullname received from Christian's SFTP plugin to a well formed Linux fullname. - T.C. button definition: TOTALCMD#BAR#DATA
%COMMANDER_PATH%\Addons\TCMC.exe 50 CMcm_CopyFullNamesToClip EMem_ConvertSSHToSlash
%COMMANDER_PATH%\WCMICONS.DLL,59
Copy SSH Path As Linux Path
%COMMANDER_PATH%\Addons
0
-1 - em_Command definition:
Implicit assumption: machine names will be 8 characters or longer. If this does not apply for you, you will have to modify the sed command accordingly.[em_ConvertSSHToSlash]
button=WCMICONS.DLL,59
cmd=start cmd.exe
param=/c pclip| sed -e "s#\\#/#g" -e "s#///Secure FTP/.\{8\}[^/]*/#/#g" | /usr/bin/xclip -i -sel clip
menu=sshpath
path=%COMMANDER_PATH%\Addons
- Name: Copy FTP Fullname As Linux Path
Purpose: Convert a fullname received from the T.C. ftp-client to a well formed Linux fullname. - T.C. button definition: TOTALCMD#BAR#DATA
%COMMANDER_PATH%\Addons\TCMC.exe 50 CMcm_CopyFullNamesToClip EMem_ConvertFtpToSlash
%COMMANDER_PATH%\WCMICONS.DLL,59
Copy FTP Fullname As Linux Path
%COMMANDER_PATH%\Addons
0
-1 - em_Command definition: [em_ConvertFtpToSlash]
button=WCMICONS.DLL,59
cmd=start cmd.exe
param=/c pclip| sed -e "s#ftp://.[^/]*/#/#g" | /usr/bin/xclip -i -sel clip
menu=ftppath
path=%COMMANDER_PATH%\Addons
- And for completeness' sake, the one that was needed most and that was the starting point:
- Name: Copy Fullname As Linux Path
Purpose: Convert a fullname received from the T.C. under Wine, i.e. in Windows notations, to a well formed Linux fullname. - T.C. button definition: TOTALCMD#BAR#DATA
%COMMANDER_PATH%\Addons\TCMC.exe 50 CMcm_CopyFullNamesToClip EMem_ConvertToLinuxSlash
%COMMANDER_PATH%\WCMICONS.DLL,59
Copy Fullname As Linux Path
%COMMANDER_PATH%\Addons
0
-1 - em_Command definition:
Note: You may have to adjust the sed expression which resolves the link C: depending on where C: points to.[em_ConvertToLinuxSlash]
button=WCMICONS.DLL,59
cmd=start cmd.exe
param=/c pclip| sed -e "s#\\#/#g" -e "s#^C:#~/.wine/drive_c#g" -e "s#^Z:##g" | /usr/bin/xclip -i -sel clip
menu=slash
path=%COMMANDER_PATH%\Addons
- Name: Copy SSH Path As Linux Path
Karl
-
- Senior Member
- Posts: 276
- Joined: 2011-11-15, 06:14 UTC
- Location: DE\BN - only part time TC user after switching to Linux ;)
Hi Karlchen!
With great pleasure i read your posts in this thread.
After i struggled some hours to try to use winepath to convert Z:\bla\blubs\ to /bla/blubs/ to pass the linux path to native linux applications that shall be started from TC running in Wine, i googled harder and found this thread.
btw, i run Linux Mint 17.1.
I copied over your Button and EM_command.
I downloaded TCMC and put it into %COMMANDER_PATH%\addons\
I also downloaded the unxtools and put it into my wine C-Drive into C:\unix\ - as the unxtools readme suggests.
I'm a bit confused where to start looking, my problem is, that when i click the button it says "file not found".
I can exclude the TCMC, that seems to be found by TC.
I guess it has to do with the SED an pclip calls from the EM COmmand, because the windows path gets put into clipboard, so the cm_copytoclipboard gets actually called by TCMC!
Would you be able to help me debugging this?
After searching for a native dualpane commander alternative for 3 years now, i finally have the motiviation to run linux and get my TC setup in wine to work (at least almost) as good as it does on windows
Maybe we can extend the TC Wiki chapters regarding use on linux... at least i would do that as soon as i get some time after my linux setup runs...
thanks already for your help!
br
seb
With great pleasure i read your posts in this thread.
After i struggled some hours to try to use winepath to convert Z:\bla\blubs\ to /bla/blubs/ to pass the linux path to native linux applications that shall be started from TC running in Wine, i googled harder and found this thread.
btw, i run Linux Mint 17.1.
I copied over your Button and EM_command.
I downloaded TCMC and put it into %COMMANDER_PATH%\addons\
I also downloaded the unxtools and put it into my wine C-Drive into C:\unix\ - as the unxtools readme suggests.
I'm a bit confused where to start looking, my problem is, that when i click the button it says "file not found".
I can exclude the TCMC, that seems to be found by TC.
I guess it has to do with the SED an pclip calls from the EM COmmand, because the windows path gets put into clipboard, so the cm_copytoclipboard gets actually called by TCMC!
Would you be able to help me debugging this?
After searching for a native dualpane commander alternative for 3 years now, i finally have the motiviation to run linux and get my TC setup in wine to work (at least almost) as good as it does on windows

Maybe we can extend the TC Wiki chapters regarding use on linux... at least i would do that as soon as i get some time after my linux setup runs...
thanks already for your help!
br
seb