AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Peeking DragDrop & Clipboard Data

 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Sean



Joined: 12 Feb 2007
Posts: 2462

PostPosted: Sat Aug 11, 2007 4:00 am    Post subject: Peeking DragDrop & Clipboard Data Reply with quote

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.


Last edited by Sean on Tue Aug 21, 2007 4:13 am; edited 2 times in total
Back to top
View user's profile Send private message
g11414
Guest





PostPosted: Sat Aug 11, 2007 6:17 am    Post subject: Reply with quote

Thanks for sharing! Smile
Back to top
Hardeep



Joined: 02 Jul 2006
Posts: 87

PostPosted: Sat Aug 11, 2007 9:20 am    Post subject: Reply with quote

Very useful Very Happy Thanks for sharing your work.
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 2462

PostPosted: Sat Aug 11, 2007 11:35 am    Post subject: Reply with quote

Thanks guys!
I updated the script a little to detect unicode strings as possible as it can using Window's provided API.
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 4710
Location: Boulder, CO

PostPosted: Sat Aug 11, 2007 3:41 pm    Post subject: Reply with quote

Fantastic! Thanks for figuring it out. Your script got into my list of favorite tools.
Back to top
View user's profile Send private message
skrommel



Joined: 30 Jul 2004
Posts: 190

PostPosted: Tue Apr 01, 2008 5:04 pm    Post subject: Reply with quote

Smile A wish come true! Almost...

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

Skrommel
_________________
www.1HourSoftware.com
Back to top
View user's profile Send private message Visit poster's website
soggos



Joined: 27 Mar 2008
Posts: 129
Location: France

PostPosted: Fri Mar 19, 2010 10:50 am    Post subject: but more great 1023 ¿ Reply with quote

Dear Sean,Very Great Now i can drop a link on my gui...

skrommel wrote:

Sad 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...

Sean wrote:
... 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:
Code:
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!...<img>
Back to top
View user's profile Send private message Visit poster's website
Sean



Joined: 12 Feb 2007
Posts: 2462

PostPosted: Fri Mar 19, 2010 12:36 pm    Post subject: Reply with quote

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.
Code:
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.
Back to top
View user's profile Send private message
soggos



Joined: 27 Mar 2008
Posts: 129
Location: France

PostPosted: Fri Mar 19, 2010 1:15 pm    Post subject: Reply with quote

Very good for me, thank's again Sean
_________________
with ahk, all is different!...<img>
Back to top
View user's profile Send private message Visit poster's website
fragman



Joined: 13 Oct 2009
Posts: 1194

PostPosted: Fri May 14, 2010 12:56 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
TLM



Joined: 21 Aug 2006
Posts: 2926
Location: The Shell

PostPosted: Mon Aug 30, 2010 6:12 pm    Post subject: Reply with quote

bump

Thanks for this!

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

Anyway, great work Very Happy
_________________
paradigm.shift:=(•_•)┌П┐RTFM||^.*∞
Back to top
View user's profile Send private message
Deo



Joined: 16 May 2010
Posts: 172

PostPosted: Fri Oct 29, 2010 11:00 am    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group