Jump to content

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

How to: Image Drag from Firefox to GUI ??


  • Please log in to reply
5 replies to this topic
sugardaddy
  • Members
  • 41 posts
  • Last active: Jan 26 2010 11:23 PM
  • Joined: 05 Aug 2006
I would like to be able to drag an image from Firefox to a GUI and be able to work with it. Specifically, I would like to copy it to a certain location.

But when I do it, the path I see in the GuiEvent is for a temp file that doesn't really exist.

How can I work with this kind of file?

Thank you

garry
  • Members
  • 2940 posts
  • Last active: Yesterday, 01:01 PM
  • Joined: 19 Apr 2005
have no solution, was playing with that, click on small picture , save picture big
(in flickr can save direct with rightclick)

MODIFIED=20100120
/*
   start script and flickr
   click on small picture, copy graphikadress
   big picture saved in c:\recorded1
*/


SetWorkingDir %A_ScriptDir%

REC        =c:\_RECORDED1
run,%COMSPEC% /C if not exist \%REC%\NUL MD %REC%,,hide

WA=%A_screenwidth%
HA=%A_screenheight%

clipboard=
EDITCOLOR=red

Gui,2:Add,Edit,c%editcolor%  x10   y2     h20  w270    vAAACC readonly,

txx3=suzhou
Gui,2: Add, Button,    x10    y30  h20  w70   gFlickr1,Flickr
Gui,2: Add, Edit,      x100   y30  w150 h20 vLac         ,%txx3%

GW:=(WA*30)/100
GH:=(HA*10)/100

Gui,2:Show,            x0   y0     h%GH%  w%GW% ,TEST
settimer,DDDD,500
return

Flickr1:
run,http://www.flickr.com/search/?q=%lac%
return


2GuiClose:
ExitApp


;=================  SETTIMER =====================================================
DDDD:
Gui,2:submit,nohide
URL=%clipboard%
nothing=

SplitPath,URL, name, dir, ext, name_no_ext, drive

stringreplace,name_no_ext,name_no_ext,_t,%nothing%,
stringreplace,name_no_ext,name_no_ext,_m,%nothing%,

URL=%dir%/%name_no_ext%_b.%ext%   ;  big
;URL=%dir%/%name_no_ext%.%ext%    ;  size normal

  if (ext="jpg" or ext="bmp")
      goto,start2
return
;---------------------------


START2:
GuiControl,2:Text,AAACC,%URL%
Guicontrolget,AAACC,2:,
Gui,2:Show,            x0   y0     h%GH%  w%GW% ,TEST
C3=%AAACC%


        SIZE7:=HttpQueryInfo(URL,5)
        ;msgbox,%size7%
        if (size7="timeout" or size7=0 or size7=-1)
        return

        if (size7=2737 or size7<3000)
           URL=%dir%/%name_no_ext%.%ext%     ;  size normal
        else
           URL=%dir%/%name_no_ext%_b.%ext%  ;  big



/*
clipboard=
settimer,DDDD,off
msgbox,%URL%
;return
*/

        if (ext="jpg" or ext="bmp")
             {
             clipboard=
             settimer,DDDD,off
             urldownloadtofile,%URL%,%rec%\%name_no_ext%.%ext%
             }

ifexist,%rec%\%name_no_ext%.%ext%
    run,%rec%\%name_no_ext%.%ext%
settimer,DDDD,500
return




;====================== function =========================================
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;-------------------------- FUNCTION GETSIZE before download -------------------------
;http://www.autohotkey.com/forum/topic10510.html
; Olfen PhiLho
;SIZE:=HttpQueryInfo(URL, 5)
;msgbox,262144,MESSAGE,SIZE = %SIZE% Byte


HttpQueryInfo(URL, QueryInfoFlag=21, Proxy="", ProxyBypass="") {
hModule := DllCall("LoadLibrary", "str", "wininet.dll")

If (Proxy != "")
AccessType=3
Else
AccessType=1

io_hInternet := DllCall("wininet\InternetOpenA"
, "str", "" ;lpszAgent
, "uint", AccessType
, "str", Proxy
, "str", ProxyBypass
, "uint", 0) ;dwFlags
If (ErrorLevel != 0 or io_hInternet = 0) {
DllCall("FreeLibrary", "uint", hModule)
return, -1
}

iou_hInternet := DllCall("wininet\InternetOpenUrlA"
, "uint", io_hInternet
, "str", url
, "str", "" ;lpszHeaders
, "uint", 0 ;dwHeadersLength
, "uint", 0x80000000 ;dwFlags: INTERNET_FLAG_RELOAD = 0x80000000 // retrieve the original item
, "uint", 0) ;dwContext
If (ErrorLevel != 0 or iou_hInternet = 0) {
DllCall("FreeLibrary", "uint", hModule)
return, -1
}

VarSetCapacity(buffer, 1024, 0)
VarSetCapacity(buffer_len, 4, 0)

Loop, 5
{
  hqi := DllCall("wininet\HttpQueryInfoA"
  , "uint", iou_hInternet
  , "uint", QueryInfoFlag ;dwInfoLevel
  , "uint", &buffer
  , "uint", &buffer_len
  , "uint", 0) ;lpdwIndex
  If (hqi = 1) {
    hqi=success
    break
  }
}

IfNotEqual, hqi, success, SetEnv, res, timeout

If (hqi = "success") {
p := &buffer
Loop
{
  l := DllCall("lstrlen", "UInt", p)
  VarSetCapacity(tmp_var, l+1, 0)
  DllCall("lstrcpy", "Str", tmp_var, "UInt", p)
  p += l + 1
  res := res  . "`n" . tmp_var
  If (*p = 0)
  Break
}
StringTrimLeft, res, res, 1
}

DllCall("wininet\InternetCloseHandle",  "uint", iou_hInternet)
DllCall("wininet\InternetCloseHandle",  "uint", io_hInternet)
DllCall("FreeLibrary", "uint", hModule)

return, res
}
;------------------------------------------------------------------
;============================ END =================================



TimSys
  • Guests
  • Last active:
  • Joined: --
>I would like to be able to drag an image from Firefox to a GUI and be able to work with it. Specifically, I would like to copy it to a certain location.

Drag = Download

=> You can use the free iMacros Firefox extension from http://wiki.imacros.net/Demo-ImageDownload

Then your AHK code can pick up this file and do with it whatever needs to be done.

sugardaddy
  • Members
  • 41 posts
  • Last active: Jan 26 2010 11:23 PM
  • Joined: 05 Aug 2006
I took a quick look at the iMacros extension (thank you for suggesting it) and decided I didn't want to try to get into that.

I like the ease of just dragging something, so I think the route I'll go is to create a folder on the desktop that I can drag links and photos to. I'll create a routine to watch that folder and do things to any file that appears there.

TLM
  • Moderators
  • 3819 posts
  • Last active:
  • Joined: 21 Aug 2006
Very easy one to do.
Heres a starter:
GUI, +AlwaysOnTop
GUI, add, text, x10 BackgroundTrans vImage, Drag and Drop image here from FireFox!
GUI, show, NA W400 H100 X400 Y100, dropWin
return

GuiDropFiles:
GuiControl, Move, Image, x10 w300 h100
GuiControl, text, Image, % "Image dropped!`n`nImage location:`n" A_GuiEvent
return

GuiClose:
ExitApp
Copy, paste, run it. Drag file from Firefox to it.
Just have to make a var := a_guievent ;)..

garry
  • Members
  • 2940 posts
  • Last active: Yesterday, 01:01 PM
  • Joined: 19 Apr 2005
thank you TLM , your script works fine , shows picture in the gui and saves to folder test
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
F1=%A_scriptdir%\test
ifnotexist,%f1%
   filecreatedir,%f1%
GUI, +AlwaysOnTop
Gui, Add, Picture, x6 y10 w120 h30 vA1,
GUI, show, NA W700 H500 X20 Y20, dropWin
return

GuiDropFiles:
GuiControl, Move, A1, x10 w680 h480
GuiControl,1:,A1,%A_GuiEvent%
filecopy,%A_GuiEvent%,%f1%
return

GuiClose:
ExitApp