AutoHotkey Community

It is currently May 27th, 2012, 12:40 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: February 16th, 2010, 5:02 pm 
Offline

Joined: July 22nd, 2008, 1:49 pm
Posts: 151
Hi.

Know that little icon that appears next to a websites name in your browser? for example the "H" logo when you goto www.autohotkey.com, i'm trying to figure out a way to retrieve that logo file or add it directly as a picture?

I've tried:

Code:
Gui, add, picture ,, www.google.com


Sorta already figured that that wouldnt work and it was abit more advanced that this, just really couldn't figure out where to start :)

If anyone would be able to point me in the right direction it would be much appriciated.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 16th, 2010, 5:04 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5482
Location: the tunnel(?=light)
You can access the logo by using the Menu command to retrieve the icon from the AHK exe itself.

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 16th, 2010, 5:07 pm 
http://en.wikipedia.org/wiki/Favicon


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 16th, 2010, 5:07 pm 
Offline

Joined: July 22nd, 2008, 1:49 pm
Posts: 151
I'm sorry, dont think i made myself clear :)

I'm not looking for the "H" logo specificly, i'm looking for a general way to retrieve logos from different webpages.

Thanks though.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 16th, 2010, 5:13 pm 
Following the statement of the wiki you can simply get a page with AHKs URLDownloadToFile and parse for the fav.ico destination link within its code.
Sample:
Quote:
<link rel="shortcut icon" href="/favicon.ico" />
afterwards you can do an URLDownloadToFile again :)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 16th, 2010, 5:18 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5482
Location: the tunnel(?=light)
As long as you're sure of the path to server if the full path isn't specified the above mentioned should work. For autohotkey:

Code:
http://www.autohotkey.com/favicon.ico

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 16th, 2010, 5:21 pm 
Offline

Joined: July 22nd, 2008, 1:49 pm
Posts: 151
Thanks alot for your quick responses. The wiki article was good, but i'm still lacking abit to get it to work :P

tried:
Code:
URLDownloadToFile, www.google.com, googlewebsite.html



But it didnt seem to download any file which i could then retrieve the path of the logo from?

Edit: tried saving in other formats aswell

Code:
URLDownloadToFile, http://www.autohotkey.com/favicon.ico, fisk.ico

Works just fine, but that requires already knowing the path to the favicon.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 16th, 2010, 6:15 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5482
Location: the tunnel(?=light)
Here is sample code using the iWeb functions to return the path to the favicon if it exists on the page. It is tested for the sites shown but I can't guarantee it will work on all sites (requires the COM Standard Library and the iWeb functions):

Code:
errLvl=
site:="MSN.com" ; www.msn.com
; site:="Home | The Root" ; www.theroot.com
; site:="Retrieving logo/icon of homepage" ; http://www.autohotkey.com/forum/viewtopic.php?p=332509
iWeb_Init()
pwb:=iWeb_getWin(site)
Loop % COM_Invoke(pwb,"document.all.tags[link].length") {
  if (COM_Invoke(pwb,"document.all.tags[link].item[" A_Index-1 "].rel") = "shortcut icon") {
    fav:=COM_Invoke(pwb,"document.all.tags[link].item[" A_Index-1 "].href")
    errLvl=true
    break
  }
}
iWeb_Release(pwb)
iWeb_Term()
if !errLvl {
  MsgBox, 48, Warning, There is no icon available from this page.
  return
}
if !InStr(favico,"http") {
  ControlGetText, url, Edit1, % site
  RegExMatch(url,"is)http://[^/]+",m)
  MsgBox % m fav
  return
}
MsgBox % fav
return

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: chaosad, jrav, Yahoo [Bot] and 22 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group