Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Peeking DragDrop & Clipboard Data


  • Please log in to reply
11 replies to this topic
Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007
It'll peek the data, especially (unicode)text, of the DragDrop & Clipboard data.
BTW, the length of the text will be limited to 1023 bytes, but it can be easily circumvented using other string-related APIs, so I'll leave it to the users.
And, it may be combined with any HexViewer script as a full DragDrop/Clipboard data viewer.

To see the contents of the DragDrop, just drag and drop the source to the GUI.
And, press the hotkey #c to see the content of the current clipboard.

DOWNLOAD DragDrop.ahk. [SKAN's Dropbox]

g11414
  • Guests
  • Last active:
  • Joined: --
Thanks for sharing! :)

Hardeep
  • Members
  • 87 posts
  • Last active: Sep 12 2007 06:40 PM
  • Joined: 02 Jul 2006
Very useful :D Thanks for sharing your work.

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007
Thanks guys!
I updated the script a little to detect unicode strings as possible as it can using Window's provided API.

Laszlo
  • Moderators
  • 4713 posts
  • Last active: Mar 31 2012 03:17 AM
  • Joined: 14 Feb 2005
Fantastic! Thanks for figuring it out. Your script got into my list of favorite tools.

skrommel
  • Members
  • 193 posts
  • Last active: Jun 07 2010 08:30 AM
  • Joined: 30 Jul 2004
:) A wish come true! Almost...

:( It crashes AutoHotkey when copying something from Internet Explorer, or it takes a break before continuing. Any ideas?

Skrommel

soggos
  • Members
  • 129 posts
  • Last active: Nov 30 2012 10:35 AM
  • Joined: 27 Mar 2008
Dear Sean,Very Great Now i can drop a link on my gui...

:( It crashes AutoHotkey when copying something from Internet Explorer, or it takes a break before continuing. Any ideas?

Skrommel

At this time, soggos have no problem with ie8, to recover a link.
But, for all text...

... the length of the text will be limited to 1023 bytes, but it can be easily circumvented using other string-related APIs, so I'll leave it to the users....

how to retrieve sData (no limit but all)?
cause i have remplaced 1023 with nSize:
IEnumFormatEtc(this)
{
	LV_Delete()
	DllCall(NumGet(NumGet(1*this)+32),"Uint",this,"Uint",1,"UintP",penum) ; DATADIR_GET=1, DATADIR_SET=2
	Loop
	{
		VarSetCapacity(FormatEtc,20,0)
		If  DllCall(NumGet(NumGet(1*penum)+12), "Uint", penum, "Uint",1, "Uint", &FormatEtc, "Uint",0)
		    Break
		0+(nFormat:=NumGet(FormatEtc,0,"Ushort"))<18 ? RegExMatch("CF_TEXT CF_BITMAP CF_METAFILEPICT CF_SYLK CF_DIF CF_TIFF CF_OEMTEXT CF_DIB CF_PALETTE CF_PENDATA CF_RIFF CF_WAVE CF_UNICODETEXT CF_ENHMETAFILE CF_HDROP CF_LOCALE CF_DIBV5", "(?:\w+\s+){" . nFormat-1 . "}(?<FORMAT>\w+\b)", CF_) : nFormat>=0x80&&nFormat<=0x83 ? RegExMatch("CF_OWNERDISPLAY CF_DSPTEXT CF_DSPBITMAP CF_DSPMETAFILEPICT", "(?:\w+\s+){" . nFormat-0x80 . "}(?<FORMAT>\w+\b)", CF_) : nFormat=0x8E ? CF_FORMAT:="CF_DSPENHMETAFILE" : CF_FORMAT:=GetClipboardFormatName(nFormat)
		VarSetCapacity(StgMedium,12,0)
		If  DllCall(NumGet(NumGet(1*this)+12), "Uint", this, "Uint", &FormatEtc, "Uint", &StgMedium)
		    Continue
		If	NumGet(StgMedium,0)=1	; TYMED_HGLOBAL=1
		{
			hData:=NumGet(StgMedium,4)
			pData:=DllCall("GlobalLock", "Uint", hData)
			nSize:=DllCall("GlobalSize", "Uint", hData)	; nSize
			; VarSetCapacity(sData,1023), DllCall("wsprintf", "str", sData, "str", DllCall("advapi32\IsTextUnicode", "Uint", pData, "Uint", nSize, "Uint", 0) ? "%S" : "%s", "Uint", pData, "Cdecl")
			VarSetCapacity(sData,nSize), DllCall("wsprintf", "str", sData, "str", DllCall("advapi32\IsTextUnicode", "Uint", pData, "Uint", nSize, "Uint", 0) ? "%S" : "%s", "Uint", pData, "Cdecl")
			DllCall("GlobalUnlock", "Uint", hData)
			LV_Add("", A_Index, CF_FORMAT, nSize, sData)
			
			if CF_FORMAT= CF_TEXT	; for putting in clipboard
			{
					Clipboard:= sData
					MsgBox , 4160 , , TEXTE> %sData% ; BUT not ALL!
				}
			; if CF_FORMAT= UniformResourceLocator	; OK
				; MsgBox , 4160 , , %sData%
			; if CF_FORMAT= FileNameW				; OK
				; MsgBox , 4160 , , %sData%
		 		
		}
		Else	RegExMatch("TYMED_NULL TYMED_FILE TYMED_ISTREAM TYMED_ISTORAGE TYMED_GDI TYMED_MFPICT TYMED_ENHMF", "(?:\w+\s+){" . Floor(ln(NumGet(StgMedium)+1)/ln(2)) . "}(?<STGMEDIUM>\w+\b)", TYMED_), LV_Add("", A_Index, CF_FORMAT, "?", TYMED_STGMEDIUM)
		DllCall("ole32\ReleaseStgMedium","Uint",&StgMedium)
	}
	DllCall(NumGet(NumGet(1*penum)+8), "Uint", penum)
	LV_ModifyCol()
}

But if sData is more great > 1023 he don't giveall!
How to Do?
with ahk, all is different!...

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007
The limit of 1023 is imposed by wsprintf API itself used in the script. I chose it due to UNICODE text and Binary data. If you only need the (ANSI) text, you may use the following instead.
nLen := DllCall("lstrlen", "Uint", pData)
VarSetCapacity(sData, nLen)
DllCall("lstrcpy", "str", sData, "Uint", pData) 

However, it's prone to crash AHK when applied to Binary Data. So, my recommendation is using UNICODE build of AHK_L and only retrieve the UNICODE text.

soggos
  • Members
  • 129 posts
  • Last active: Nov 30 2012 10:35 AM
  • Joined: 27 Mar 2008
Very good for me, thank's again Sean
with ahk, all is different!...

fragman
  • Members
  • 1591 posts
  • Last active: Nov 12 2012 08:51 PM
  • Joined: 13 Oct 2009
How would one detect if the user is currently dragging a file (without dropping it onto a GUI) ?

Reason is, I'm programming tabs for windows explorer, and would like to be able to toggle to tab under mouse when the user drags a file over it.

TLM
  • Administrators
  • 3864 posts
  • Last active:
  • Joined: 21 Aug 2006
bump

Thanks for this!

I'm wondering if this could be considered a replacement for ClipSpy??

Anyway, great work :D

Posted Image

don't duplicate, iterate!


Deo
  • Members
  • 199 posts
  • Last active: Jan 31 2014 03:19 PM
  • Joined: 16 May 2010
how can i get notification thet item is dragging over the gui window from this code?
got it

the only problem - current code won't allow multi files dragging, how to fix this?