Currently in Chrome you can drag a url from the address bar onto the desktop (Win7) and it creates a .URL shortcut file with the URL address information inside. I can currently drag that file into my GUI script and read the info out of it but I would like to be able to skip that step and drag straight from Chrome to my GUI.
I did some searching and found out about the dataTransfer object and the getData method but I have no idea how I would go about accessing this in AHKL. Is anyone able to point me in the right direction?
Thanks
Heres info about dataTransfer and getData
<!-- m -->http://help.dottoro.com/ljmpcqdb.php<!-- m -->
<!-- m -->http://help.dottoro.com/ljolwfvj.php<!-- m -->
I also found an example in JS but I have no idea how I would apply it to AHK
<!-- m -->http://stackoverflow... ... file-names<!-- m -->
Drag URL info from Chrome Address Bar to GUI
Started by
Alfihar
, Jul 15 2012 09:03 AM
5 replies to this topic
#1
-
Posted 15 July 2012 - 09:03 AM
:oops: Ok, Ive managed to make some progress, mostly with the drag and drop script from here http://www.autohotke...pic.php?t=21966
However, now I keep getting all my results in chinese characters. I know it must be something to do with the encoding.. but I have no idea what I need to change or where the problem is. Anyone able to help?
Here is the Drag and Drop code im using (Unicode,32bit,win7)
However, now I keep getting all my results in chinese characters. I know it must be something to do with the encoding.. but I have no idea what I need to change or where the problem is. Anyone able to help?
1 DragContext ? TYMED_ISTREAM 2 DragImageBits 8524 U 3 text/x-moz-url 106 h 4 FileGroupDescriptorW 596 5 FileContents 68 䥛瑮牥敮却潨瑲畣嵴剕㵌瑨灴⼺氯愮瑵桯瑯敫敮⽴潤獣䘯湵瑣潩獮栮浴 6 UniformResourceLocatorW 86 h 7 UniformResourceLocator 43 瑨灴⼺氯愮瑵桯瑯敫敮⽴潤獣䘯湵瑣潩獮栮浴䴀 8 CF_UNICODETEXT 86 h 9 CF_TEXT 43 瑨灴⼺氯愮瑵桯瑯敫敮⽴潤獣䘯湵瑣潩獮栮浴䴀
Here is the Drag and Drop code im using (Unicode,32bit,win7)
#NoTrayIcon #SingleInstance Force GuiOpen: TempString := "" Gui, +LastFound Gui, Add, ListView, R20 W600, #|Format|Size|Data Gui, Show, X10 Y10 hGui := WinExist() VarSetCapacity(IDropSource,24,0), NumPut(&IDropSource+4,IDropSource), nParams=31132 Loop, Parse, nParams NumPut(RegisterCallback("IDropSource","",A_LoopField,A_Index-1),IDropSource,4*A_Index) VarSetCapacity(IDropTarget,32,0), NumPut(&IDropTarget+4,IDropTarget), nParams=3116516 Loop, Parse, nParams NumPut(RegisterCallback("IDropTarget","",A_LoopField,A_Index-1),IDropTarget,4*A_Index) DllCall("ole32\OleInitialize","Uint",0) DllCall("ole32\RegisterDragDrop","Uint",hGui,"Uint",&IDropTarget) Return GuiClose: ;Clipboard := TempString Gui, Destroy DllCall("ole32\RevokeDragDrop","Uint",hGui) DllCall("ole32\OleUninitialize") ExitApp #C::DllCall("ole32\OleGetClipboard","UintP",pdata)=0 ? (IEnumFormatEtc(pdata),DllCall(NumGet(NumGet(1*pdata)+8),"Uint",pdata)) : "" IDropSource(this, escape=0, key=0) { If A_EventInfo = 3 hResult := escape ? 0x00040101 : key&3 ? 0 : 0x00040100 Else If A_EventInfo = 4 hResult := 0x00040102 Else If A_EventInfo = 0 hResult := 0, NumPut(this,key+0) Else hResult := 0 Return hResult } IDropTarget(this, pdata=0, key=0, x=0, y=0, peffect=0) { If A_EventInfo = 4 NumPut(NumGet(y+0)&5,y+0) Else If A_EventInfo = 3 NumPut(NumGet(peffect+0)&5,peffect+0) Else If A_EventInfo = 6 NumPut(NumGet(peffect+0)&5,peffect+0), IEnumFormatEtc(pdata) Else If A_EventInfo = 0 NumPut(this,key+0) Return 0 } 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) VarSetCapacity(sData,1023), 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) } 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() LVRows := LV_GetCount() Loop, % LVRows { LV_GetText(C1, A_Index, 1) LV_GetText(C2, A_Index, 2) LV_GetText(C3, A_Index, 3) LV_GetText(C4, A_Index, 4) TempString := TempString . C1 . " " . C2 . " " . C3 . " " . C4 . "`n" } Clipboard := TempString MsgBox % Clipboard } GetClipboardFormatName(nFormat) { VarSetCapacity(sFormat, 255) DllCall("GetClipboardFormatName", "Uint", nFormat, "str", sFormat, "Uint", 256) Return sFormat }
#2
-
Posted 15 July 2012 - 10:58 PM
Take a look at this post. AHK_L has Com support already built in. The "ComObjConnect" line was the key for me.
<!-- l --><a class="postlink-local" href="http://www.autohotkey.com/community/viewtopic.php?f=1&t=85778#p533003">viewtopic.php?f=1&t=85778#p533003</a><!-- l -->
<!-- l --><a class="postlink-local" href="http://www.autohotkey.com/community/viewtopic.php?f=1&t=85778#p533003">viewtopic.php?f=1&t=85778#p533003</a><!-- l -->
#3
-
Posted 15 July 2012 - 11:51 PM
"Some people, when confronted with a problem, think I know, I'll use regular expressions. Now they have two problems."
- Jamie Zawinski
OMG SOOO SIMPLE
Thanks so much!
I was really out of my depth there.
how do I set this to [SOLVED]
Thanks so much!
I was really out of my depth there.
how do I set this to [SOLVED]
#4
-
Posted 16 July 2012 - 12:11 AM
Just edit your main post and you will be able to edit the title
#5
-
Posted 16 July 2012 - 12:15 AM
Sjc1000 - Insert inspirational quote here!
PLEASE find me on the IRC if you have questions. I'm never on the forum anymore.
OMG SOOO SIMPLE
Thanks so much!
I was really out of my depth there.
how do I set this to [SOLVED]
You're welcome. Just an aside, I found to my surprise EditPadLite7 will also act as a drop target for many urls from browsers if you highlight the address text and drag it. It has support for url text with underline and launches on double click. Works with at least chrome/chromium, firefox and MaxThon.
Also I was surprised to learn those same browsers will open multiple urls from the command line in tabs. XP and later I think the command tail is something like 8191 characters. So I kind of abandoned my Gui and just use text files with categorized urls. But either way can be a lot faster than tab sessions. Good luck with your utility.
#6
-
Posted 16 July 2012 - 02:27 AM
"Some people, when confronted with a problem, think I know, I'll use regular expressions. Now they have two problems."
- Jamie Zawinski