Author Topic: Load file content to clipboard  (Read 28560 times)

pncdaspropagandas

  • Contributor
  • Active Member
  • *****
  • Posts: 93
    • View Profile
Load file content to clipboard
« on: August 01, 2017, 18:46:30 »
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)

  • Administrator
  • VIP Member
  • *****
  • Posts: 4411
    • View Profile
    • Multi Commander
Re: Load file content to clipboard
« Reply #1 on: August 02, 2017, 01:45:37 »
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

  • Contributor
  • Active Member
  • *****
  • Posts: 93
    • View Profile
Re: Load file content to clipboard
« Reply #2 on: August 02, 2017, 03:45:02 »
True indeed!

Mathias (Author)

  • Administrator
  • VIP Member
  • *****
  • Posts: 4411
    • View Profile
    • Multi Commander
Re: Load file content to clipboard
« Reply #3 on: August 02, 2017, 18:40:50 »
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

  • Contributor
  • Active Member
  • *****
  • Posts: 93
    • View Profile
Re: Load file content to clipboard
« Reply #4 on: August 03, 2017, 12:39:15 »
 :D :D :D