SHARE
TWEET

Untitled

a guest Jul 8th, 2013 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Module[{temp, t2, CopyFileOverwrite, datafile, dataloc, csfile,
  2.   exefile, file, NRun},
  3.  temp = FileNameJoin[{$TemporaryDirectory,
  4.     "ClipboardTransparency314241234"}];
  5.  NRun[s_] := (str = OpenWrite[FileNameJoin[{temp, "temp.bat"}]];
  6.    WriteString[str, s];
  7.    Import["!" <> Close[str], "Text"];);
  8.  If[DirectoryQ[temp], t2 = Directory[];
  9.   SetDirectory[temp];
  10.   Map[Function[DeleteFile[#]], FileNames[]];
  11.   SetDirectory[t2];
  12.   DeleteDirectory[temp, DeleteContents -> True];, Null];
  13.  CreateDirectory[temp];
  14.  CopyFile[
  15.   FileNameJoin[{$InstallationDirectory, "SystemFiles", "Links",
  16.     "NETLink", "Wolfram.NETLink.dll"}],
  17.   FileNameJoin[{temp, "Wolfram.NETLink.dll"}]];
  18.  csfile = FileNameJoin[{temp, "File.cs"}];
  19.  exefile = FileNameJoin[{temp, "File.exe"}];
  20.  file = OpenWrite[csfile];
  21.  WriteString[file, "using System;
  22.           using Wolfram.NETLink;
  23.           using System.IO;
  24.           using System.Drawing;
  25.           using System.Windows.Forms;
  26.  
  27.           public class File{
  28.            [STAThread]
  29.            public static void Main(String[] args) {
  30.               string input = System.Console.In.ReadToEnd();
  31.               byte[] bytes = Convert.FromBase64String(input);
  32.               Stream stream = new MemoryStream(bytes);
  33.               IDataObject dataObject = new DataObject();
  34.               dataObject.SetData(args[0], stream);
  35.               Clipboard.SetDataObject(dataObject, true);
  36.             }
  37.           }"];
  38.  Close[file];
  39.  NRun["cd " <> temp "
  40.       C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\csc.exe  \
  41. /reference:Wolfram.NETLink.dll File.cs"];
  42.  WriteToClipboard[type_, data_] := (
  43.    Time[HoldForm[
  44.      dataloc = FileNameJoin[{temp, "data.txt"}];
  45.      datafile = OpenWrite[dataloc];
  46.      
  47.      WriteString[datafile, data];
  48.      Close[datafile];
  49.      ]];
  50.    NRun["type " <> dataloc <> " | " <> exefile <> " " <> type];
  51.    );]
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top