Hello Everybody,
it often happens that, before you download a picture, a document or a song, you first want to check, whether you already have that or a similar file on your hard disk.
Unfortunately, I have not yet found a parameter that would transfer the clipboard content to the TC search function or would automatically insert the searched text into the "Search for:" field or pass it as an argument to a TC command.
I use the browser plugin ]Search from popup or context menu (https://addons.mozilla <dot> org/de/firefox/addon/searchfrompopuporcontextmenu), which can be used to pass selected text to a search engine or a local application.
Does anyone have an idea, how to pass a marked text from the web to the TC search function in a simple way, i.e. without AHK, without Everything and without saving it to a list first (because you always search for a single filename)?
Thank you in advance for your ideas
Clickable URL disabled by Moderator.
Same thread in German > https://ghisler.ch/board/viewtopic.php?t=78380
Passing selected text from web or from clipboard as a parameter to TC search function
Moderators: Hacker, petermad, Stefan2, white
Re: Passing selected text from web or from clipboard as a parameter to TC search function
2Box333
The logic of TC is devoid of debugging functions when solving such tasks, which is why resort to automation tools, if not external like AHK, then built-in (bat+wget/curl/etc, vbs/js, PoSh).
For example, I wrote myself a vbs code for downloading via links from the clipboard a long time ago.
The logic of TC is devoid of debugging functions when solving such tasks, which is why resort to automation tools, if not external like AHK, then built-in (bat+wget/curl/etc, vbs/js, PoSh).
For example, I wrote myself a vbs code for downloading via links from the clipboard a long time ago.
Overquoting is evil! 👎
Re: Passing selected text from web or from clipboard as a parameter to TC search function
An example of how to get the clipboard content and turn it into a variable (within cmd; which I've been using for wget/yt-dlp downloads):
Code: Select all
:: Get url from the clipboard
for /f "delims=" %%i in ('mshta "javascript:var x=clipboardData.getData('text');if(x) new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1).Write(x);close();"') do set url=%%i
#278521 User License
Total Commander [always the latest version, including betas] x86/x64 on Win10 x64/Android 10/15
Total Commander [always the latest version, including betas] x86/x64 on Win10 x64/Android 10/15
Re: Passing selected text from web or from clipboard as a parameter to TC search function
2beb
It's a strange approach when WSH is used for one task, and a third-party utility is used for another, and for some reason it's all stuffed into bat, duplicating the creation of a variable. A triple hybrid instead of a full-fledged code.
It's a strange approach when WSH is used for one task, and a third-party utility is used for another, and for some reason it's all stuffed into bat, duplicating the creation of a variable. A triple hybrid instead of a full-fledged code.

Overquoting is evil! 👎
Re: Passing selected text from web or from clipboard as a parameter to TC search function
Here's a more compact version that utilizes powershell function:
Code: Select all
for /f "tokens=* delims=" %%i in ('powershell -command "Get-Clipboard"') do set "url=%%i"
echo %url%
[Total Commander usercmd]:
Code: Select all
[em_wget_clip]
cmd=%commander_path%\Plugins\app\Downloads\wget_clip.cmd
Code: Select all
@echo off
chcp 65001
REM runtime variables parsing
Setlocal EnableDelayedExpansion
REM path;cli;app
path %path%;%commander_path%\Plugins\app\Downloads
REM wget parameters (universal)
set params=-S -N --no-if-modified-since --no-hsts --user-agent="Mozilla"
REM downloads folder location
for /f "tokens=2,*" %%c in (
'reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v {374DE290-123F-4565-9164-39C4925E467B}'
) do set downloads=%%d
REM retrieving url from clipboard
for /f "tokens=* delims=" %%i in ('powershell -command "Get-Clipboard"') do set "url=%%i"
REM downloading...
@echo.&@echo downloading...&@echo.&@echo "%url%"&@echo.
wget !params! "%url%" -P "%downloads%"
REM checking output...
if ERRORLEVEL 1 (goto ERROR) else (goto OK)
:ERROR
:: wait 7 seconds then exit
@echo There's no URL in the clipboard
ping -n 8 ::1 >nul
:OK
exit/b
#278521 User License
Total Commander [always the latest version, including betas] x86/x64 on Win10 x64/Android 10/15
Total Commander [always the latest version, including betas] x86/x64 on Win10 x64/Android 10/15