; SendToClipboardAsContents
; Mark Breault, 2005-08, 2008-08
; AutoIt v3.2.12.1
;
; Purpose
;   Copy the contents of any plain-text file (regardless of its file
;   name extension) to Windows Clipboard.
;
; Setup
;   Compile this script; save the .exe in Program Files.
;   Put a shortcut to the .exe in your SendTo folder.
;   Rename the shortcut "Clipboard as contents".
;
; Usage
;   Right-click any plain-text file (regardless of its file name
;   extension) in Windows Explorer; choose Send To |
;   Clipboard as contents; then paste.
;
; Notes
;   IMPORTANT: FileRead() reads plain-text files only. The script no
;   longer attempts to discriminate between text and non-text files;
;   non-text files are simply not copied.
;   Checks $CmdLine[0] for the presence of a command line parameter;
;   if there isn't one, e.g., if the script was run directly rather
;   than via Send To, reading $CmdLine[1] gives an out-of-range error.
;   ISSUES: Sometimes reports an error writing to the Clipboard when
;   no error occurred.
;   This script is open source software.


If $CmdLine[0] < 1 Then
	MsgBox(16, @ScriptName, "Launch this program via Send To")
	Exit
EndIf
$filespec = $CmdLine[1]
If Not ClipPut(FileRead($filespec, FileGetSize($filespec))) Then
	MsgBox(16, @ScriptName, "Error writing to Windows Clipboard")
EndIf