Jump to content

Clipboard with Files


 Share

Recommended Posts

Hey,

i did a little app which gets all text data from clipboard an put that into a listview, where you can easyly get this back,when you need it again.

the next step is, that, when user put a file into the clipboard, this should also be shown with name (and maybe) path in the listview and when you click this, this file will be in clipboard again.

when this ist not possible, at least filename and path should be in clipboard.

is that possible?

Link to comment
Share on other sites

Hey,

i did a little app which gets all text data from clipboard an put that into a listview, where you can easyly get this back,when you need it again.

the next step is, that, when user put a file into the clipboard, this should also be shown with name (and maybe) path in the listview and when you click this, this file will be in clipboard again.

when this ist not possible, at least filename and path should be in clipboard.

is that possible?

Try the example scripts for all the _Clipboard* functions in the help file to get a feel for what you do with the various formats.

:P

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

I have an example (most is from DragDrop :P ): But only copy works. cut/shortcut don't work.

#include<Memory.au3>
#include<ClipBoard.au3>

Global Const $DROPFILES = "DWORD pFiles; int pt[2]; int fNC; int fWide;"

;===============================================================================
;
; 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)
    $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

; Prog@ndy
Func _CreatePREFERREDDROPEFFECT($dwEffect)
    Local $pMem = _MemGlobalAlloc(4, $GHND) ; 4 bytes - 1 DWORD
    If Not $pMem Then Return SetError(1,0,0)
    DllStructSetData(DllStructCreate("DWORD",$pMem),1,$dwEffect)
    Return $pMem
EndFunc

; Author: Prog@ndy
Func _DragDrop_SIZEOF($tagStruct)
    Return DllStructGetSize(DllStructCreate($tagStruct, 1))
EndFunc   ;==>_DragDrop_SIZEOF

Global Const $CFSTR_PREFERREDDROPEFFECT = "Preferred DropEffect"
Global Const $CF_PREFERREDDROPEFFECT = _ClipBoard_RegisterFormat($CFSTR_PREFERREDDROPEFFECT)

Global Const $DROPEFFECT_NONE = 0
Global Const $DROPEFFECT_COPY = 1
Global Const $DROPEFFECT_MOVE = 2
Global Const $DROPEFFECT_LINK = 4
Global Const $DROPEFFECT_SCROLL = 0x80000000


$hGUI = GUICreate("")

$hClip = _ClipBoard_Open($hGUI)

_ClipBoard_Empty()

$Files = "C:\file.txt"

$HDROP = _CreateDROPFILES($Files)
$DROPEFFECT = _CreatePREFERREDDROPEFFECT($DROPEFFECT_COPY)


_ClipBoard_SetDataEx($HDROP, $CF_HDROP)
_ClipBoard_SetDataEx($DROPEFFECT, $CF_PREFERREDDROPEFFECT)
_ClipBoard_Close()

//Edit: get files from Clipboard works like WM_DROPFILES for DragDrop http://www.autoitscript.com/forum/index.ph...c=90831&hl=

(get data from clipboardformat $CF_HDROP and use the same funcs as in WM_DROPFILES to get the files.)

Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

  • 1 year later...

Searched for ages for something like this, great work :(... found you're addition on the German board about file moving and added it to this example. Use

$DROPEFFECT = _CreatePREFERREDDROPEFFECT($DROPEFFECT_COPY) to copy and

$DROPEFFECT = _CreatePREFERREDDROPEFFECT($DROPEFFECT_MOVE) to move files.

; 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

#include<Memory.au3>
#include<ClipBoard.au3>

Global Const $DROPFILES = "DWORD pFiles; int pt[2]; int fNC; int fWide;"

;===============================================================================
;
; 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)
    $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

; 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

; Author: Prog@ndy
Func _DragDrop_SIZEOF($tagStruct)
    Return DllStructGetSize(DllStructCreate($tagStruct, 1))
EndFunc   ;==>_DragDrop_SIZEOF

Global Const $CFSTR_PREFERREDDROPEFFECT = "Preferred DropEffect"
Global Const $CF_PREFERREDDROPEFFECT = _ClipBoard_RegisterFormat($CFSTR_PREFERREDDROPEFFECT)

Global Const $DROPEFFECT_NONE = 0
Global Const $DROPEFFECT_COPY = 1
Global Const $DROPEFFECT_MOVE = 2
Global Const $DROPEFFECT_LINK = 4
Global Const $DROPEFFECT_SCROLL = 0x80000000

$hGUI = GUICreate("")
$hClip = _ClipBoard_Open($hGUI)
_ClipBoard_Empty()

$Files = @ScriptDir & "\test.txt"

$HDROP = _CreateDROPFILES($Files)
;$DROPEFFECT = _CreatePREFERREDDROPEFFECT($DROPEFFECT_COPY)
$DROPEFFECT = _CreatePREFERREDDROPEFFECT($DROPEFFECT_MOVE)

_ClipBoard_SetDataEx($HDROP, $CF_HDROP)
_ClipBoard_SetDataEx($DROPEFFECT, $CF_PREFERREDDROPEFFECT)
_ClipBoard_Close()
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...