Multi Commander > Script

Load file content to clipboard

(1/1)

pncdaspropagandas:
In my PC, if I try to use the internal function to load file content to clipboard on a rather large file, MC hangs. So I created a script that decides when to use the built in function and when to use clip.exe

MC Script:
@var $focused_file = GetSourceFocusPath();
@var $focused_file_size = GetFileSize($focused_file);
@var $mcinstallpath = GetTagValue("${mcinstallpath}");

// MultiCommander doesn't support files bigger than ???KB, so we have to use window's clip.exe program
if ($focused_file_size > 307200)
{
   //LogAppInfo('C:\Windows\System32\wscript.exe "'  + $mcinstallpath ^ '\Tools\run_invisible\run_invisible_bat_1_arg.vbs" "' + $mcinstallpath ^ '\Tools\run_invisible\load_file_content_to_clipboard.bat" "' + $focused_file + '"');
   MC.Run CMD={'C:\Windows\System32\wscript.exe'} ARG={'"' + $mcinstallpath ^ '\Tools\run_invisible\run_invisible_bat_1_arg.vbs" "' + $mcinstallpath ^ '\Tools\run_invisible\load_file_content_to_clipboard.bat" "' + $focused_file + '"'}
}
else
{
   @var $focused_file_content = LoadStringFromFile($focused_file);
   SetClipboardText($focused_file_content);
}

run_invisible_bat_1_arg.vbs
Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
'MsgBox(WScript.Arguments(0))
WshShell.Run """" & WScript.Arguments(0) & """ """ & WScript.Arguments(1) & """",0,true

load_file_content_to_clipboard.bat
clip < %1


The reason to use a bat file instead of just running clip < %1 is that when you execute a command line with no visible cmd, the stdout doen't work.

Mathias (Author):
That work for unicode data. but if the program that you paste into only reads the ascii clipboard it is not set. since there is some limit in a external lib. I can probably fix that with a workaround

pncdaspropagandas:
True indeed!

Mathias (Author):
Script function fixed in newest beta.. (2672+)

Also Menu > Tools > ToClipboard > File Content as Text
Is now enabled. (it was disabled before because of some crash issue..  now fixed)

pncdaspropagandas:
 :D :D :D

Navigation

[0] Message Index

Go to full version