What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Download image from URL and save locally

Download image from URL and save locally
Author: Message:
ketchup_blade
New Member
*


Posts: 8
Joined: Jul 2005
O.P. Download image from URL and save locally
Hello,

for my script, I need to be able to save locally an image that is available at a specific URL, for example: http://shoutbox.menthix.net/images/smilies/xso_wink.gif

I'm not used to scripting with Jscript, and i can't find a way to download and save this binary file locally.

Any tips?

kb
12-05-2006 01:39 PM
Profile E-Mail PM Find Quote Report
andrewdodd13
Senior Member
****

Avatar
Oh so retro

Posts: 870
Reputation: 16
34 / Male / Flag
Joined: Jan 2005
RE: Download image from URL and save locally
You can use the following:

var dlURL = "http://shoutbox.menthix.net/images/smilies/xso_wink.gif";
var localfile = FSO.BuildPath("<PATH TO SAVED LOCATION>");
var ret = Interop.Call('urlmon', 'URLDownloadToFileW', 0, dlURL, localfile, 0, 0);
[Image: AndrewsStyle.png]
12-05-2006 04:14 PM
Profile E-Mail PM Web Find Quote Report
John Anderton
Elite Member
*****

Avatar

Posts: 3908
Reputation: 80
37 / Male / Flag
Joined: Nov 2004
Status: Away
RE: Download image from URL and save locally
I don't know if i should save this but imo there isn't any practical use to this script. If you know the url why not open it in your browser and save it? :-/
Or if you want to save wallpapers, use a program like Download Accelerator Plus (DAP) that allows addition of links to download queue.
That's just my 2 cents :)
[

KarunAB.com
]

[img]http://gamercards.exophase.com/459422.png[
/img]
12-05-2006 04:17 PM
Profile E-Mail PM Web Find Quote Report
Felu
Veteran Member
*****


Posts: 2223
Reputation: 72
30 / Male / Flag
Joined: Apr 2006
Status: Away
RE: Download image from URL and save locally
quote:
Originally posted by andrewdodd13
var dlURL = "http://shoutbox.menthix.net/images/smilies/xso_wink.gif";
var localfile = FSO.BuildPath("<PATH TO SAVED LOCATION>");
var ret = Interop.Call('urlmon', 'URLDownloadToFileW', 0, dlURL, localfile, 0, 0);
You forgot to declare FSO [Image: msn_tongue.gif]
code:
var FSO = new ActiveXObject('Scripting.FileSystemObject');
quote:
Originally posted by John Anderton
I don't know if i should save this but imo there isn't any practical use to this script. If you know the url why not open it in your browser and save it?
With a script [Image: xso_undecided.gif]. This might be used for downloading Script Updates etc. Though downloading a image is not needed :P.

This post was edited on 12-05-2006 at 04:34 PM by Felu.
12-05-2006 04:32 PM
Profile E-Mail PM Web Find Quote Report
andrewdodd13
Senior Member
****

Avatar
Oh so retro

Posts: 870
Reputation: 16
34 / Male / Flag
Joined: Jan 2005
RE: RE: Download image from URL and save locally
quote:
Originally posted by -!Felu!-
quote:
Originally posted by andrewdodd13
var dlURL = "http://shoutbox.menthix.net/images/smilies/xso_wink.gif";
var localfile = FSO.BuildPath("<PATH TO SAVED LOCATION>");
var ret = Interop.Call('urlmon', 'URLDownloadToFileW', 0, dlURL, localfile, 0, 0);
You forgot to declare FSO [Image: msn_tongue.gif]
code:
var FSO = new ActiveXObject('Scripting.FileSystemObject');

Oops, that was silly! I just copied some code I'd already used and modified it slightly, should've checked it :|
[Image: AndrewsStyle.png]
12-05-2006 04:51 PM
Profile E-Mail PM Web Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
36 / Male / Flag
Joined: Aug 2006
RE: Download image from URL and save locally
quote:
Originally posted by John Anderton
If you know the url why not open it in your browser and save it?

This could be useful if someone send you a link to an image... (just check start and end of the link for certain text such as .png and so on). You can then download it without having to open a browser or DAP (which both open wuite slow in comparison to just saving it directly and then possibly opening it in a default app such as "Windows Fax and Picture Viewer"
<Eljay> "Problems encountered: shit blew up" :zippy:
12-05-2006 05:07 PM
Profile PM Find Quote Report
John Anderton
Elite Member
*****

Avatar

Posts: 3908
Reputation: 80
37 / Male / Flag
Joined: Nov 2004
Status: Away
RE: Download image from URL and save locally
quote:
Originally posted by -!Felu!-
Though downloading a image is not needed
quote:
Originally posted by ketchup_blade's thread title
Download image from URL and save locally
Any other questions? :P

quote:
Originally posted by SpunkyLoveMuff
You can then download it without having to open a browser
Ok. There is clicking a link and seeing it in the browser and deciding if you want to save it and letting a script download the image to a location and open in with windows fax and picture viewer, deciding to keep it or not and then either deleting it or moving it to the appropriate storage place (for people like me to keep different types of wallpapers/images in different folders)
Some how, the earlier seems lesser work to me. And opening a browser, looking and saving would be quicker than the other method :P
[

KarunAB.com
]

[img]http://gamercards.exophase.com/459422.png[
/img]
12-05-2006 07:21 PM
Profile E-Mail PM Web Find Quote Report
ketchup_blade
New Member
*


Posts: 8
Joined: Jul 2005
O.P. RE: RE: Download image from URL and save locally
quote:
Originally posted by John Anderton
I don't know if i should save this but imo there isn't any practical use to this script. If you know the url why not open it in your browser and save it? :-/


Yes there is.  Actually, you can't assign the Messenger.MyDisplayPicture property with an image URL (unlike when you select your image manually within Messenger).  So if I want to dynamically use an image from the Web, I need to first save it on the disk.

Thanks all for the code, it works!  I thought that the FSO didn't work with binary files...

kb
12-05-2006 08:38 PM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On