Fr33b0w Posted May 19, 2010 Posted May 19, 2010 How can I put one simple file in clipboard so I can use it later? I did try few times but dont know where I am wrong... File is in same dir where script is... Those lines blow doesn't make sense since I did try few times and it wouldnt work... so its all mixed up... It should be just 2 lines... but dont know how to write it right... ;$file = FileOpen("file.txt", 0) ;$clip = FileRead($file, 1) FileCopy("file.txt", $file) ClipPut($file,1) ;ClipPut($clip) ;$file = "file.txt" ;ClipPut("file.txt")
KaFu Posted May 19, 2010 Posted May 19, 2010 Copy/Cut files to clipboard... my signature is full of wonders ... OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
Fr33b0w Posted May 19, 2010 Author Posted May 19, 2010 For half an hour I did try to understand what is all about in that link but I cant understand "_CreateDROPFILES" and "_CreatePREFERREDDROPEFFECT($DROPEFFECT_COPY)"... I can guess that many would tell me "leave the autoit and go play with the ball" but I am too fat for 1 ball... Anyway... There is no simple command which would get one file in clipboard? I just need to get it in clipboard. I would manualy press "ctrl + v" in explorer and paste that file somewhere I have a need for... I only need the way how can I get one file in clipboard, like if there would be a command like: FileCopy("file.txt", $file) Clipput($file) Something like that? It should be just few lines... Can You or any other guy in here give me simple 2 line example how can I put a file "file.txt" which is in same dir as script in clipboard? PS: I think that your FF plugin is great and many other stuff which You wrote and I could not understand at the moment (or many other moments in the future). Anyway I hope You guys support people who likes autoit and they are not programmers or script coders, or... that clever. Thats why I ask for simple things... At least I hope they must be simple because I dont get it and it should be just few lines. Thanks in advance!
czardas Posted May 19, 2010 Posted May 19, 2010 There is a function called _ClipPutFile which should do the trick. It's in the help file. operator64 ArrayWorkshop
Moderators SmOke_N Posted May 19, 2010 Moderators Posted May 19, 2010 ClipPut(FileRead($file)) ? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Fr33b0w Posted May 19, 2010 Author Posted May 19, 2010 This WORKS! It is simple code! Thanks a LOT! $file = @ScriptDir & "file.txt" $fTest = _ClipPutFile($file) I could try also second example! Thanks to all!
czardas Posted May 19, 2010 Posted May 19, 2010 (edited) Good job. For some reason I thought you might need to include a backslash in the file name, though if it's working for you, then fine. #Include <Misc.au3> $hFile = @ScriptDir & "\file.txt" _ClipPutFile($hFile) Edited May 19, 2010 by czardas operator64 ArrayWorkshop
Fr33b0w Posted May 20, 2010 Author Posted May 20, 2010 Good job. For some reason I thought you might need to include a backslash in the file name, though if it's working for you, then fine. #Include <Misc.au3> $hFile = @ScriptDir & "\file.txt" _ClipPutFile($hFile) Yes yes it is included in my script but here isnt... Thanks a lot!
KaFu Posted May 20, 2010 Posted May 20, 2010 There is a function called _ClipPutFile which should do the trick. It's in the help file. Lol, never saw that one . But the above one also allows you not only to copy to clipboard but also to cut (move) files... wrapped it a little bit... expandcollapse popup#include<Memory.au3> #include<ClipBoard.au3> $sFiles = @ScriptDir & "\test1.txt" & "|" & @ScriptDir & "\test2.txt" _ClipPutFileEx($sFiles, 2) Func _ClipPutFileEx($sFiles = "", $iOpType = 1) ; $sFiles, list of files, separated by "|" ; $iOpType: 1 = Copy, 2 = Move (Cut) Local Const $DROPFILES = "DWORD pFiles; int pt[2]; int fNC; int fWide;" Local Const $CFSTR_PREFERREDDROPEFFECT = "Preferred DropEffect" Local Const $CF_PREFERREDDROPEFFECT = _ClipBoard_RegisterFormat($CFSTR_PREFERREDDROPEFFECT) Local Const $DROPEFFECT_NONE = 0 Local Const $DROPEFFECT_COPY = 1 Local Const $DROPEFFECT_MOVE = 2 Local Const $DROPEFFECT_LINK = 4 Local Const $DROPEFFECT_SCROLL = 0x80000000 Local $hClip = _ClipBoard_Open(WinGetHandle("Program Manager")) _ClipBoard_Empty() $HDROP = _CreateDROPFILES($sFiles,$DROPFILES) Local $DROPEFFECT Switch $iOpType Case 2 $DROPEFFECT = _CreatePREFERREDDROPEFFECT($DROPEFFECT_MOVE) case Else $DROPEFFECT = _CreatePREFERREDDROPEFFECT($DROPEFFECT_COPY) EndSwitch _ClipBoard_SetDataEx($HDROP, $CF_HDROP) _ClipBoard_SetDataEx($DROPEFFECT, $CF_PREFERREDDROPEFFECT) _ClipBoard_Close() EndFunc ;==>_ClipPutFileEx ; ProgAndy ; http://www.autoitscript.com/forum/index.php?showtopic=91046&view=findpost&p=654849 ; http://www.autoit.de/index.php?page=Thread&postID=81909&highlight=hdrop#post81909 ;=============================================================================== ; ; Function Name: _CreateDROPFILES ; Description:: Creates a DROPFILES-structure ; Parameter(s): $Files - Pipe-separated list of files to copy: example: C:\File1.bin|D:\AnotherFile.dat ; Requirement(s): COM/OLE UDF ; Return Value(s): HGLOBAL-Pointer to a DROPFILES structure ; Author(s): prog@ndy ; ;=============================================================================== ; Func _CreateDROPFILES($Files,$DROPFILES) $Files = String($Files) $hMem = _MemGlobalAlloc(_DragDrop_SIZEOF($DROPFILES) + ((StringLen($Files) + 2) * 2), $GPTR) $Files = StringSplit($Files, "|") $stDROPFILES = DllStructCreate($DROPFILES, $hMem) $hPtr = $hMem + DllStructGetSize($stDROPFILES) DllStructSetData($stDROPFILES, "fWide", 1) DllStructSetData($stDROPFILES, 1, DllStructGetSize($stDROPFILES)) For $i = 1 To $Files[0] $next = DllStructCreate("wchar[" & StringLen($Files[$i]) + 1 & "]", $hPtr) DllStructSetData($next, 1, $Files[$i] & ChrW(0)) $hPtr += (StringLen($Files[$i]) + 1) * 2 Next $next = DllStructCreate("wchar[1]", $hPtr) DllStructSetData($next, 1, ChrW(0)) Return $hMem EndFunc ;==>_CreateDROPFILES ; Prog@ndy Func _CreatePREFERREDDROPEFFECT($dwEffect) Local $pMem = _MemGlobalAlloc(4, $GPTR) ; 4 bytes - 1 DWORD If Not $pMem Then Return SetError(1, 0, 0) DllStructSetData(DllStructCreate("DWORD", $pMem), 1, $dwEffect) Return $pMem EndFunc ;==>_CreatePREFERREDDROPEFFECT ; Author: Prog@ndy Func _DragDrop_SIZEOF($tagStruct) Return DllStructGetSize(DllStructCreate($tagStruct, 1)) EndFunc ;==>_DragDrop_SIZEOF OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
czardas Posted May 20, 2010 Posted May 20, 2010 Lol, never saw that one . But the above one also allows you not only to copy to clipboard but also to cut (move) files... wrapped it a little bit...It will take me a bit of time to figure this one out. Thanks for posting however: it is interesting. Although it's not the same thing, it reminds me of one time when I started to write a certain bitwise function before I realized that it had a name and already existed. operator64 ArrayWorkshop
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now