Jump to content

IE Save Image as


Recommended Posts

Greetings all!

I want to open a web page and then save one of the images on that web page on my hard drive, just like we would do manually, by right clicking on the image and then choosing the "Save Image as"

Since the image is the result of a dynamic img src URL, and for other security reasons too, I can't download the image directly from its img src URL. The web page MUST be opened on the browser and only after that, the image can be saved locally. This the reason I need to mimic the "Save Image as" stuff.

Is there any ways of doing that without using the coordinates and the mouse movement features?

I'm trying the path below, but I'm stuck at this since I couldn't find more information to achieve my target.

#include <IE.au3>
$oIE = _IECreate ("http://www.autoitscript.com/")
$oImg = _IEImgGetCollection ($oIE, 5)

Thanks in advance.

Edited by piratao2
Link to comment
Share on other sites

It's not easy. I made it and posted it in the German forum, but AM, the Server is renewed, so I can't get it. :D

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

I thought that after getting the handle for the image, I just would need some more instructions to mimic the save image as...

Do you have the link to the forum that you said so I can search there later? Also, tell me some keywords that I should use on the search to find your mentioned posted.

Thanks!

Link to comment
Share on other sites

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

it would be helpful for analysis if you post the original URL

The original URL is not available for you guys since it is an intranet system that uses user/password for login. Only after the successful login I can plot the graphics that I need to download. And the graphics are not a direct link to an image, the img src code point to an asp script, not the real image. Then, the image displayed on the screen is the result of this asp script that runs on the server. So I can tell you for sure that it is not possible to play with the HTML code on it and neither download the image directly without opening the page and getting the image from the page itself. If you try to download the image directly using its img src url, you will not download anything else than a blank picture. This behavior happens for security purposes of the intranet site.

I hope I don't need to go deeper on why I must download the image using the IE "save picture as". Trust me, I must use this, but I'd like to avoid mouse moves and clicks to minimize the chance of fail.

Thanks!

Link to comment
Share on other sites

I believe you are looking for the InetGet Funtion.

:D

The inetget would not work since it would open a new session to the server, and I must use the same browser session that I used to login to the system. If I use the inetget I would download a wrong and invalid picture.

Thanks anyway.

Anybody else knows how to mimic the save picture as?

Link to comment
Share on other sites

The DOM does not give you the ability to programatically save files for security reasons.

I don't know of another way to do this other than mouse clicks.

If you are not awre of it, _IEPropertyGet will allow you to get the screen coordinates of an element, like an image, however... but you'll still need to simulate mouse clicks.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

The DOM does not give you the ability to programatically save files for security reasons.

I don't know of another way to do this other than mouse clicks.

If you are not awre of it, _IEPropertyGet will allow you to get the screen coordinates of an element, like an image, however... but you'll still need to simulate mouse clicks.

Dale

Thanks Dale, but in this case I will prefer other path, to simulate hot keys on Firefox. In Firefox, with Send("^s"), I can easily save the entire page (with images) and then grab the images that I need from my local hard drive.

The only thing remaining to make it work on Firefox, is to detect if the page has been already loaded in Firefox. Do you know how to do that?

Thanks!

Link to comment
Share on other sites

My example is online again... http://www.autoit.de/index.php?page=Thread...44300#post44300

#include <GUIConstants.au3>
#include <IE.au3>
#include<ClipBoard.au3>
#include<GDIPlus.au3>
#include<Winapi.au3>
MsgBox(0,"","Um das Bild zu holen, wird lieder die Zwischenablage gelöscht.")
#region - GUI Create
GUICreate('The IMG')
$oie = _IECreateEmbedded()
$ie = GUICtrlCreateObj($oie,10,10,100,50)
GUICtrlSetState(-1,$GUI_HIDE)
_IENavigate($oie,"http://www.easybux.de/login.php?r=")




;get the Image:
_GDIPlus_Startup()
$form = _IEFormGetCollection($oie,0)
$code = _IEFormElementGetObjByName($form,"code")
$r = $oie.document.body.createControlRange()
$x = $code.parentNode.childNodes.item(1)
$r.add($x)
$r.select()
$r.execCommand('Copy')
Sleep(500)
_ClipBoard_Open(0)
$z = _ClipBoard_GetDataEx($CF_BITMAP)
$y = _GDIPlus_BitmapCreateFromHBITMAP($z)
_ClipBoard_Close()
FileDelete(@TempDir&"\code2434.bmp")
_GDIPlus_ImageSaveToFile($y,@TempDir&"\code2434.bmp")

;Show Image in GUI
$Img = GUICtrlCreatePic(@TempDir&"\code2434.bmp",10,20,_GDIPlus_ImageGetWidth($y),_GDIPlus_ImageGetHeight($y))

_GDIPlus_BitmapDispose($y)
$x = ""
_GDIPlus_Shutdown()
;End Get Image


GUISetState()
#endregion

#region - GUI SelectLoop
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
    EndSelect
WEnd
#endregion

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...