How to import clipping items into the path editing bar

English support forum

Moderators: Hacker, petermad, Stefan2, white

Fla$her
Power Member
Power Member
Posts: 2982
Joined: 2020-01-18, 04:03 UTC

Re: How to import clipping items into the path editing bar

Post by *Fla$her »

tuska wrote: 2024-11-04, 21:48 UTC The problem occurs when I want to insert the clipboard contents into a path in the 'path editing bar'
that already has more than 259 characters.
I didn't understand how path editing could be related to a script. But that's not the problem, it's trying to open the same directory. Fixed.
Although this is a different error. You still need a full name. For example, I am perfectly navigating this path:
Spoiler
C:\LongPath\LongPath\LongPath\LongPath\LongPath\LongPath\LongPath\LongPath\LongPath\LongPath\LongPath\LongPath\LongPath\LongPath\LongPath\LongPath\LongPath\LongPath\LongPath\LongPath\LongPath\LongPath\LongPath\LongPath\LongPath\LongPath\LongPath\LongPath\LongPath\LongPath\LongPath\LongPath\LongPath\LongPath\LongPath\LongPath\LongPath\LongPath\LongPath\LongPath\LongPath\LongPath\LongPath\LongPath\LongPath\LongPath\LongPath\Long Path\
param=""%COMMANDER_PATH%\Plugins\wfx\Registry" "%P%Z""
The first parameter is incorrect. There is nothing in the syntax about the path to the plugin folder. It talks about its name on the wfx list (cm_OpenNetwork).
tuska wrote: 2024-11-04, 22:01 UTC File: _OneDrive_%USERPROFILE%-OneDrive_redirected to_D-Daten-OneDrive.lnk
Is it not wfx? How does this path (_OneDrive_C:\...lnk) with the cd command?
tuska wrote: 2024-11-04, 21:48 UTC When I click on the shortcut (.lnk), the following path is called up on my PC: D:\Daten\OneDrive\ .
But this behavior doesn't apply to this script. I have another script to follow the links.

Among other things, I recommend that you test the code on the clipboard with mixed text, where there is a path. For example, you select something in a browser with the presence of a path, an environment variable, {GUID} or a registry key without worrying about extra characters. That's the beauty of this code.
Added the algorithm to the end of the spoiler.
Overquoting is evil! 👎
User avatar
tuska
Power Member
Power Member
Posts: 4046
Joined: 2007-05-21, 12:17 UTC

Re: How to import clipping items into the path editing bar

Post by *tuska »

2Fla$her
I'm sorry, but it still doesn't work for me and I'm certainly not the right tester for it.
No offense, I can't go on with this topic, because sometimes I don't even understand what you mean here (hobby user).
Fla$her
Power Member
Power Member
Posts: 2982
Joined: 2020-01-18, 04:03 UTC

Re: How to import clipping items into the path editing bar

Post by *Fla$her »

2tuska
If something is unclear to you, just ask a question. I will always answer. It's not that hard.
However, I do not know what is so difficult I wrote there, so that with your experience it might become unclear.

First of all, I am interested in the problematic path. Have problems with copy-paste?
The parameters should look something like this: param="Registry "%P%Z""
Instead of 'Registry', you can have the name that you specified during installation.
I also don't see an answer about the _OneDrive_ prefix and the cd command.
Overquoting is evil! 👎
User avatar
tuska
Power Member
Power Member
Posts: 4046
Joined: 2007-05-21, 12:17 UTC

Re: How to import clipping items into the path editing bar

Post by *tuska »

2Fla$her
OK, let's try again.

With your reference to: param="Registry "%P%Z"", the topic of ‘paths >259 characters’ is no longer an issue.
In the usercmd.ini file, further "" quotation marks were then added automatically.
usercmd.ini

Code: Select all

[em_TCNavigatorByPathFromClipboard]
button=
cmd=%COMMANDER_PATH%\Tools\Skripts\TCNavigatorByPathFromClipboard.vbs
param=""Registry "%P%Z"""
menu=%COMMANDER_PATH%\Tools\Skripts\TCNavigatorByPathFromClipboard.vbs|Parameters: "Registry "%P%Z""|https://www.ghisler.ch/board/viewtopic.php?p=463015#p463015
The script has problems with spaces in the names of folders and files, because an error message appears.
*.lnk files (with/without spaces) also do not work (we can leave out the link to OneDrive).

This concludes my tests.
For me, this topic is finally closed.
Fla$her
Power Member
Power Member
Posts: 2982
Joined: 2020-01-18, 04:03 UTC

Re: How to import clipping items into the path editing bar

Post by *Fla$her »

tuska wrote: 2024-11-05, 21:29 UTC In the usercmd.ini file, further "" quotation marks were then added automatically.
No, no. I've given the line for usercmd.ini, not for the button.
param="Registry "%P%Z"", but not param=""Registry "%P%Z"""
People, giving examples with usercmd.ini, very often get confused with quotation marks themselves. That's why I'm always in favor of giving examples with button codes:

Code: Select all

TOTALCMD#BAR#DATA
%COMMANDER_PATH%\Tools\Skripts\TCNavigatorByPathFromClipboard.vbs
Registry "%P%Z"
wcmicon2.dll,4
Navigate to the path, registry key, or GUID specified on the clipboard
tuska wrote: 2024-11-05, 21:29 UTC For me, this topic is finally closed.
Now imagine that everyone will answer you exactly the same way, without waiting for an indication of mistakes, when you try to help others...
Overquoting is evil! 👎
User avatar
tuska
Power Member
Power Member
Posts: 4046
Joined: 2007-05-21, 12:17 UTC

Re: How to import clipping items into the path editing bar

Post by *tuska »

Fla$her wrote: 2024-11-05, 21:53 UTC
tuska wrote: 2024-11-05, 21:29 UTC For me, this topic is finally closed.
Now imagine that everyone will answer you exactly the same way, without waiting for an indication of mistakes,
when you try to help others...
I tried to sign off as a tester for your topic, unfortunately once again without success. ;-)
Reasons:
- The OP found a solution for himself and showed no further interest in your script (and not the NirSoft solution either).
- I have been using the solution from Horst.Epp (NirSoft utilities) for years and therefore don't really need the .vbs script.
So no offense intended... :)

Where are we now?
- Thanks to your further targeted advice, the problems mentioned here (spaces, *.lnk files) no longer exist.
  Regarding the .lnk to OneDrive, I had two links in which the wrong destination was set for one of the .lnks,
  i.e. this problem has also been solved.
  I could have saved a lot of time if I had the correct ButtonCODE and em_CODE at the beginning :idea: ;-)

- I can do just as much with your script as with the NirSoft solution:
  %COMMANDER_PATH%\Tools\NirCmd\nircmd.exe exec show %COMMANDER_EXE% /O /S /A /L="~$clipboard$
  However, a professional user can probably do more with the .vb script.
TCNavigatorByPathFromClipboard.vbs - author: Fla$her
Spoiler: Original title...
TCNavigatorByPathFromClipboard.vbs (save with ANSI/UTF-16, create a em_command/button with the script path and specified param's):

Code: Select all

'——————————————————————————————— VBS ———————————————————————————————
' Assignment: Smart navigating to an object in the active panel by
' file/folder name, registry key, or GUID specified in the clipboard

' Parameters: "<name of the registry plugin in wfx-list>" "%P%Z"
'———————————————————————————————— Author: Flasher (11.08.2013) © ———
Option Explicit: Dim oWSH, oFSO, R, A, C, oREx, F
Const Title = " Navigating a path in the TC panel"
If WSH.Arguments.Count <> 2 Then MsgBox "Specify two parameters!", 262192, Title: WSH.Quit
Set oWSH = CreateObject("WScript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")
On Error Resume Next
R = "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3\1407"
A = oWSH.RegRead(R): If A > 0 Or Err.Number <> 0 Then oWSH.RegWrite R, 0, "REG_DWORD"
C = CreateObject("htmlfile").ParentWindow.ClipboardData.GetData("text")
If A > 0 Then oWSH.RegWrite R, A, "REG_DWORD"
On Error Goto 0: If Len(C) = 0 Then Quit 0
Set oREx = New RegExp
With oREx
  .IgnoreCase = 1
  .Pattern = "(H[CK]|(::)?\{|%|[A-Z]:)[^\r\n""]+[^\s\\""]"
  If .Test(C) Then
    C = .Execute(C)(0)
  Else .Pattern = " *[^\s/|:\\<*?>""][^\r\n\t|:<*?>""]*"
    If .Test(C) Then C = RTrim(.Execute(C)(0)) Else Quit 1
  End If : .Pattern = "^(::)?\{"
End With
C = Replace(Replace(Replace(C, " \ ", "\"), " / ", "/"), """", "")
If InStr(1, "|HK|HC|", "|" & Left(C, 2) & "|", 1) Then
  If Right(C, 1) =  "]" Then C = Left(C, Len(C) - 1)
  R = InStr(C, ":") : If R = 4 Or R = 5 Then _
  C = Left(C, R - 1) & Mid(C, R + 1)
  C = oFSO.BuildPath(Replace(C, "/", "\"), "\")
  Select Case UCase(Left(C, InStr(C, "\") - 1))
    Case "HKCU" C = "HKEY_CURRENT_USER"   & Mid(C, 5)
    Case "HKLM" C = "HKEY_LOCAL_MACHINE"  & Mid(C, 5)
    Case "HKCR" C = "HKEY_CLASSES_ROOT"   & Mid(C, 5)
    Case "HKCC" C = "HKEY_CURRENT_CONFIG" & Mid(C, 5)
    Case "HKU"  C = "HKEY_USERS" & Mid(C, 4)
  End Select : On Error Resume Next : oWSH.RegRead(C)
  Do Until Err.Number = 0
    On Error Goto 0
    If InStr(C, "\") = Len(C) Then Exit Do
    C = oFSO.GetParentFolderName(C) & "\"
    On Error Resume Next : oWSH.RegRead(C)
  Loop : C = "\\\" & WSH.Arguments(0) & "\" & C
ElseIf Not oREx.Test(C) Then
  oREx.Pattern = "^(%|[A-Z]:)?[^:?*<|>]+"
  If oREx.Test(C) Then C = oWSH.ExpandEnvironmentStrings(oREx.Execute(C)(0)) Else Quit 1
  oREx.Pattern = ".+/.+\\.+|.+\\.+/.+" : If oREx.Test(C) Then _
  oREx.Pattern = "(.+)[\\/][^\\/]+[\\/]?$" :_
  If oREx.Test(C) Then Set C = oREx.Execute(C)(0) :_
  If oFSO.FolderExists("\\?\" & C) + oFSO.FileExists("\\?\" & C) = 0 Then C = C.Submatches(0)
    If Mid(C, 2, 1) = ":" Then
      F = Left(C, Len(C) - 1)
      If oFSO.FileExists("\\?\" & C) + oFSO.FolderExists("\\?\" & C) = 0 Then _
      If oFSO.FileExists("\\?\" & F) + oFSO.FolderExists("\\?\" & F) < 0 Then C = F
    Else
      C = WSH.Arguments(1) & C
    If oFSO.FileExists("\\?\" & C) + oFSO.FolderExists("\\?\" & C) = 0 Then
      For R = 3 To UBound(Split(Replace(C, "/", "\"), "\"))
        If oFSO.FolderExists("\\?\" & C) Then R = 0 : Exit For Else C = oFSO.GetParentFolderName(C)
      Next : If R Then Quit 1
    End If
  End If
  If StrComp(oFSO.BuildPath(C, "\"), WSH.Arguments(1), 1) = 0 Then Quit 0
  If oFSO.FolderExists("\\?\" & C) + oFSO.FileExists("\\?\" & C) = 0 Then Quit 1 Else C = C & "\:"
Else On Error Resume Next
  If Left(C, 1) = "{" Then C = "::" & C
  If CreateObject("Shell.Application").NameSpace("shell:" & C) Is Nothing Then Quit 1
  If Err Then Quit 1
End If
If StrComp(oFSO.BuildPath(C, "\"), WSH.Arguments(1), 1) = 0 Then Quit 0
oWSH.Sendkeys "^{F10}": oWSH.Run """%COMMANDER_EXE%"" /A /O /S """ & C & """": Quit 0


Sub Quit(T)
  If T Then MsgBox "The contents of the clipboard are not equivalent" & vbCr &_
  "to an existing path in the system or registry !", 262192, Space(24) & Title
  Set oFSO = Nothing: Set oWSH = Nothing: Set oREx = Nothing: WSH.Quit
End Sub
Work algorithm:
  • If both slashes are present in the path to the missing directory/file, the parent folder will become the object to be navigated.
  • Registry keys can be written as abbreviations (HKCU, HKCR, HKLM, HKCC, HCU) in any register and have ':' at the end.
  • If a parameter or a non-existent registry key is specified, it will jump to an existing hive in the path chain.
  • The separator in the path chain can be a forward or back slash, including those with extra spaces on both sides.
  • Long paths (more than 259 characters), relative paths, and paths with environment variables are supported.
  • Extra trailing spaces, tabs, line breaks, quotation marks, square brackets can be indicated.
  • In the relative path chain, all constituent components are also checked for presence.
  • Forbidden characters at the end of file and directory paths are trimmed.
  • A virtual directory can be opened by {GUID} or ::{GUID}.
BUTTON - TCNavigatorByPathFromClipboard.vbs

Code: Select all

TOTALCMD#BAR#DATA
%COMMANDER_PATH%\Tools\Skripts\TCNavigatorByPathFromClipboard.vbs
Registry "%P%Z"
wcmicon2.dll,4
Path\to\TCNavigatorByPathFromClipboard.vbs Parameter: Registry "%P%Z"|Navigate to the path, registry key, or GUID specified on the clipboard|https://www.ghisler.ch/board/viewtopic.php?p=463229#p463229|How to import clipping items into the path editing bar


-1
BUTTON - em_TCNavigatorByPathFromClipboard

Code: Select all

TOTALCMD#BAR#DATA
em_TCNavigatorByPathFromClipboard

wciconex.dll
em_TCNavigatorByPathFromClipboard || wfx_registry_5.2|Path\to\TCNavigatorByPathFromClipboard.vbs Parameter: Registry "%P%Z"|https://www.ghisler.ch/board/viewtopic.php?p=463015#p463015|How to import clipping items into the path editing bar

0
-1
%COMMANDER_PATH%\usercmd.ini

Code: Select all

[em_TCNavigatorByPathFromClipboard]
button=
cmd=%COMMANDER_PATH%\Tools\Skripts\TCNavigatorByPathFromClipboard.vbs
param="Registry "%P%Z""
menu=%COMMANDER_PATH%\Tools\Skripts\TCNavigatorByPathFromClipboard.vbs|Parameters: "Registry "%P%Z""|https://www.ghisler.ch/board/viewtopic.php?p=463015#p463015
EDIT:
Added Work algorithm.
See: TCNavigatorByPathFromClipboard.vbs - author: Fla$her


Windows 11 Pro (x64) Version 23H2 (OS Build 22631.4391) | TC 11.50b4 x64/x86
NirSoft utilities 2.8.7.232 - 23.4.2024 | Download links at the very bottom...
Registry 5.2 | CoRegistry 1.1.0.0
Last edited by tuska on 2024-11-06, 23:23 UTC, edited 1 time in total.
Fla$her
Power Member
Power Member
Posts: 2982
Joined: 2020-01-18, 04:03 UTC

Re: How to import clipping items into the path editing bar

Post by *Fla$her »

tuska wrote: 2024-11-06, 13:43 UTC - I have been using the solution from Horst.Epp (NirSoft utilities) for years and therefore don't really need the .vbs script.
So no offense intended... :)
I also used this kind of simple solutions a long time ago, until I got tired of solving a bunch of annoying problems with correct and accurate selection.
tuska wrote: 2024-11-06, 13:43 UTC Where are we now?
Thanks for the tests.
tuska wrote: 2024-11-06, 13:43 UTC  I could have saved a lot of time if I had the correct ButtonCODE and em_CODE at the beginning :idea: ;-)
This is surprising to me, considering that you are by no means a beginner. There is a concept of syntax. When you use descriptions of command programs (cmd in particular), do you rely only on examples? The same applies to the description in the TC help, where there are also no examples, but people understand from the description what is meant in the specified syntax.
tuska wrote: 2024-11-06, 13:43 UTC - I can do just as much with your script as with the NirSoft solution:
  %COMMANDER_PATH%\Tools\NirCmd\nircmd.exe exec show %COMMANDER_EXE% /O /S /A /L="~$clipboard$
:shock: And again you surprise. You write long manuals on various things, including Everything, and for some reason you yourself do not want to read the bottom description under the spoilerr, which I pointed out earlier, to see the cardinal differences. >>>
Fla$her wrote: 2024-11-04, 22:52 UTC Added the algorithm to the end of the spoiler.
Even the script name already contains things that you can't make your button...
Overquoting is evil! 👎
User avatar
tuska
Power Member
Power Member
Posts: 4046
Joined: 2007-05-21, 12:17 UTC

Re: How to import clipping items into the path editing bar

Post by *tuska »

Fla$her wrote: 2024-11-06, 18:07 UTC There is a concept of syntax. When you use descriptions of command programs (cmd in particular), do you rely only on examples?
Yes.
Fla$her wrote: 2024-11-06, 18:07 UTC ... for some reason you yourself do not want to read the bottom description under the spoiler, which I pointed out earlier,
    to see the cardinal differences. ...
Of course I read your “Work algorithm:”.

However, only this point of the “Work algorithm:” currently affects me:
“Long paths (more than 259 characters), relative paths, and paths with environment variables are supported.”
Until further notice, I'll leave the rest to the professionals.
User avatar
tuska
Power Member
Power Member
Posts: 4046
Joined: 2007-05-21, 12:17 UTC

Re: How to import clipping items into the path editing bar

Post by *tuska »

HISTORY.TXT wrote:06.11.24 Release Total Commander 11.50 beta 5
04.11.24 Added: New pseudo environment variable %$CLIPNAME1%, %$CLIPNAME2% etc.: Inserts line 1, line 2 etc. from clipboard,
                         characters replaced like with $CLIPNAME, removes leading and trailing spaces (32/64)
04.11.24 Added: New pseudo environment variable %$CLIPNAME0%: Same as %$CLIPNAME%, but replaces line breaks with spaces (32/64)
04.11.24 Added: New pseudo environment variable %$CLIPNAME% inserts up to 8191 characters from clipboard,
                         replaces forbidden characters *?|<> with underscores_ (32/64)
04.11.24 Added: New pseudo environment variable %$CLIPBOARD1%, %$CLIPBOARD2% etc.: Inserts line 1, line 2 etc. from clipboard, otherwise unmodified (32/64)
04.11.24 Added: New pseudo environment variable %$CLIPBOARD0%: Same as %$CLIPBOARD%, but replaces line breaks with spaces (32/64)
04.11.24 Added: New pseudo environment variable %$CLIPBOARD% inserts up to 8191 unmodified characters from the clipboard (32/64)
macleod
Junior Member
Junior Member
Posts: 86
Joined: 2016-06-12, 07:32 UTC

Re: How to import clipping items into the path editing bar

Post by *macleod »

I'm not sure, if I'm doing something wrong, but parameter %$CLIPBOARD% (or others) always inserts the text between %$ and % ("CLIPBOARD"), instead of the content of clipboard.
User avatar
petermad
Power Member
Power Member
Posts: 16001
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: How to import clipping items into the path editing bar

Post by *petermad »

2macleod
You can only use %$CLIPBOARD% in the Command field.
In the Parameters field you need to use %|$CLIPBOARD|
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Post Reply