Jump to content

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

URLGet - Internet Explorer based Downloader


  • Please log in to reply
43 replies to this topic
Maestr0
  • Members
  • 652 posts
  • Last active: Aug 17 2019 06:07 PM
  • Joined: 18 Oct 2008
I'd like to help, but the file in that thread is a 404 :(

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005

I'd like to help


I will thankful if you could demonstrate in AHK 1.0, since I will have to adapt it into Gentee.

but the file in that thread is a 404 :(


I have inserted a link to my Dropbox in Title post.
kWo4Lk1.png

Maestr0
  • Members
  • 652 posts
  • Last active: Aug 17 2019 06:07 PM
  • Joined: 18 Oct 2008
Seans' script was not doing what I thought it would do, which is just supply the URL.
However, searching the forums, I found some sample script you gave that does:
Gui +LastFound +AlwaysOnTop
hI := DllCall( "LoadLibrary", Str,"RichEd20.dll" ), Gui1 := WinExist(),  W:=600, H:=50
RE1 := RichE( Gui1, 5, 15, W, H, hI )
RE2 := RichE( Gui1, 5, 65, W, H, hI )
Gui, Add, Button, x450 y120 w150 h25 gRetriveText, Retrieve RichEdit Text
Gui, Show, w610 , Drag and Drop Internet Links BElo
Return

RichE( hW, X,Y,W,H, hI ) { ; Thanks corrupt http://www.autohotkey.com/forum/viewtopic.php?t=19421
Return DllCall( "CreateWindowEx", UInt,0x200, Str,"RichEdit20A", Str,Null, UInt,0x50000004
                           ,Int,X, Int,Y, Int,W, Int,H, UInt,hW, UInt,0, UInt,hI, UInt,0 )
}

RetriveText:
 Gui +OwnDialogs
 ControlGetText, RET1,, ahk_id %RE1%
 ControlGetText, RET2,, ahk_id %RE2%
 MsgBox, % RET1 "`n" RET2 
Return

GuiClose:
 ExitApp
source: <!-- l --><a class="postlink-local" href="http://www.autohotkey.com/community/viewtopic.php?t=44943">viewtopic.php?t=44943</a><!-- l -->

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005

I found some sample script you gave


I had suggested that because OP specifically mentioned that he wanted to drag-drop favicon.
RichEdit method does not work if you drag-drop a link from webpage :(

Maestr0
  • Members
  • 652 posts
  • Last active: Aug 17 2019 06:07 PM
  • Joined: 18 Oct 2008
You sure? I just dragged the link from Chrome and PaleMoon and it worked just fine with all of them. I think it didn't work with IE9 because of UAC, will have to check on that.

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005

You sure?


When I tested with Google Chrome, the RichEdit controls accepted Internet Links drag-dropped from any part of the page. Unfortunately, with IE 6 and FF 2, it only works for favicon dragged from address-bar.


Now I am on XP-SP3 and IE 8. It does not work!

Maestr0
  • Members
  • 652 posts
  • Last active: Aug 17 2019 06:07 PM
  • Joined: 18 Oct 2008

Now I am on XP-SP3 and IE 8. It does not work!


I've tried XP-SP3 and IE 8 and indeed it does not work... but with XP-SP3 and Chrome, it does work... it's not the code that's the issue, it's IE... right? I don't see a problem requiring people to not use IE if they want to drag and drop.

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005

it's not the code that's the issue, it's IE... right?


Some code is missing!
I tried url-drag-drop on WORDPAD ( msftedit.dll, Classname:RICHEDIT50W ) and it works!
I am still experimenting.. will let you know if anything clicks.

Maestr0
  • Members
  • 652 posts
  • Last active: Aug 17 2019 06:07 PM
  • Joined: 18 Oct 2008
Excellent, let me know if I can help from this end.

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005

Some code is missing!

When we run Sean's script and drag-drop URL from IE webpage onto GUI, the first item received is UntrustedDragDrop :(.
AFAI had googled, it is not possible for RichEdit to accept UntrustedDragDrop unless the control is registered with RegisterDragDrop() and events are handled. Back to square one, I attempted again to trim Sean's code and have been successful. I will post it here in a short while.

:)

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005
Code updated! New Version 0.4

Bug fixed: I rebooted my machine and found that script ( v0.3 ) was not working!
The hardcoded value for UniformResourceLocator was the culprit.
Seemingly, "UniformResourceLocator" is not a constant and varies with reboot.
I have now applied RegisterWindowMessage() to tackle this phenomenon.


[color=#225599]/*
     ____       _ ____                  _   _ ____  _
    / ___|_   _(_)  _ \ _ __ ___  _ __ | | | |  _ \| |
   | |  _| | | | | | | | '__/ _ \| '_ \| | | | |_) | |
   | |_| | |_| | | |_| | | | (_) | |_) | |_| |  _ <| |___
    \____|\__,_|_|____/|_|  \___/| .__/ \___/|_| \_\_____|
                                 |_|
   Wrapper to handle URL-Drag-Drop on to GUI / GuiControl
   http://www.autohotkey.com/community/viewtopic.php?p=572120#p572120
   
   Adapted by SKAN - Suresh Kumar  A N / [email protected]
   Version 0.4 / Created: 06-Oct-2012 / Modified: 06-Oct-2012

   Original code by Sean,  Peeking DragDrop & Clipboard Data
   http://www.autohotkey.com/community/viewtopic.php?t=21966

*/[/color]

RegisterDragDrop( hWnd ) {
 Static hGui, IDropTarget
  If ( hWnd <> 0  ) {
       VarSetCapacity( IDropTarget, 32, 0 ),     hGui := hWnd
       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 )
       Return ! DllCall( "ole32\RegisterDragDrop", UInt,hGui, UInt,&IDropTarget )
  }
  Else Return ! DllCall( "ole32\RevokeDragDrop", UInt,hGui ), hGui := 0
              , DllCall( "ole32\OleUninitialize" )
}


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 ) {
 Static URL_Ansi, StrGet := "StrGet", Label := "GuiDropURL"
 [color=#FF0000]Global DropURL[/color]

 If ! URL_Ansi
      URL_Ansi := DllCall( "RegisterWindowMessage", Str,"UniformResourceLocator", UInt )

 DllCall( NumGet(NumGet(this+0)+32), UInt,this, UInt,1, UIntP,pEnum ), DropURL := ""

 Loop {
 	 VarSetCapacity( FormatEtc,20,0 )
	 If DllCall( NumGet( NumGet(pEnum+0)+12 ), UInt,pEnum, UInt,1, UInt, &FormatEtc, Int,0 )
		  Break
   If ( ( nFormat := NumGet(FormatEtc, 0, "UShort" ) ) <> URL_Ansi )
      Continue
   VarSetCapacity( StgMedium,12,0 )
	 If DllCall( NumGet( NumGet(this+0)+12 ), UInt,this, UInt,&FormatEtc, UInt,&StgMedium )
      Continue
   hData := NumGet( StgMedium,4 )
   pData := DllCall( "GlobalLock", UInt,hData )
   DropURL := A_IsUnicode ? %StrGet%( pData, "" )
                          : DllCall( "MulDiv", UInt,pData, Int,1, Int,1, Str )
   DllCall( "GlobalUnlock", UInt,hData )
   DllCall( "ole32\ReleaseStgMedium", UInt,&StgMedium )
 }

 DllCall( NumGet( NumGet(pEnum+0)+8 ), UInt,pEnum )

 If ( DropURL && [color=#FF0000]IsLabel( "GuiDropURL" )[/color] )
    SetTimer, %Label%, -1
}

Example :: Implementing GuiDropURL in GUI script:

#SingleInstance	Force
Gui +AlwaysOnTop
Gui, Font, s10
Gui, Add, Edit, w650 R9 hwnd[color=#FF0000]hEdit[/color]
[color=#FF4000]RegisterDragDrop([/color] [color=#FF0000]hEdit[/color] [color=#FF4000])[/color]
OnExit, GuiClose
Gui, Show,, URL-Drag-Drop
Return ;                                                 [color=#008000]// end of auto-execute section //[/color]

[color=#AA0000]GuiDropURL:[/color]
 Edit_Prepend( hEdit, DropURL "`r`n" )
Return

[color=#AA0000]GuiDropFiles:[/color]
[color=#008000] ; This routine will trigger only if you drop files on area NOT occupied by Edit Control![/color]
Return

[color=#AA0000]GuiClose:[/color]
 [color=#FF4040]RegisterDragDrop( False )[/color]
 OnExit
 ExitApp
Return

Edit_Prepend( hEdit, Text ) { ;www.autohotkey.com/community/viewtopic.php?p=565894#p565894
 DllCall( "SendMessage", UInt,hEdit, UInt,0xB1, UInt,0 , UInt,0     )      ; EM_SETSEL
 DllCall( "SendMessage", UInt,hEdit, UInt,0xC2, UInt,0 , UInt,&Text )      ; EM_REPLACESEL
 DllCall( "SendMessage", UInt,hEdit, UInt,0xB1, UInt,0 , UInt,0     )      ; EM_SETSEL
}

[color=#FF4040]; Copy/Paste GuiDropURL wrapper below.[/color]


Maestr0
  • Members
  • 652 posts
  • Last active: Aug 17 2019 06:07 PM
  • Joined: 18 Oct 2008
It works only if I use Autohotkey basic and NOT IE (like Chrome).
If I use AHK_L it won't work with any browser...

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005
:roll: Windows 7?

Everything works fine for me in:

OS: XP SP3 32Bit
AHK: AHK 1.0 / AHK_Lw 1.1.08 32 Bit
Browsers: Google Chrome 22.0.1229.79 / Internet Explorer 8.0.6001 / Firefox Portable 15.0.1

Tomorrow, I will be testing it on Windows 7 64bit + AHK 1.0

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005

If I use AHK_L it won't work with any browser...


Maybe your AHK_L.exe has elevated privileges?
See this post by Zaelia

I tested it with AHK_Lw 32-bit & AHK Classic on Windows 7 x64. ( no logon screen - admin is default )
I am unable to drag/drop url from IE webpage. Address bar link works though!
With Google chrome everything works alright. The laptop I borrowed did not have any other browser!