SavePictureAs
Web function.
The SavePictureAs function saves an HTML element referring to a picture.
Usage
It simulates a right click on an HTML element which is a picture and the selection in the context menu of the Save Picture As option.
Syntax
ret=SavePictureAs(<html_descriptor>, <path> [,<filename>])
Parameters
<html_descriptor>, identifier for the HTML element to save. See HTML descriptor for each HTML objects identification. Use Recording mode for generating automatically the descriptor (just record a click on the picture).
<path>, string, directory where to save the file.
<filename>, string, optional parameter to force the name of the file under which the image is saved. NOTE that the extension cannot be changed, the extension stays the one as provided by the web site. <filename> MUST NOT include a path or an extension.
When <filename> is not specified, the picture name is created from the url of the picture. If for any reason, a valid name cannot be generated, SavePictureAs generates an automatic filename, bitmapxxxx.
Return value
Ret, numeric return code. The function returns 0 if successfull. If the file cannot be created (or overwritten), the function returns 26. If an Internet error occurs, a negative error code is returned. You can use this return code for Error Handling.
List of negative error codes
-1
No browser in use (no previous UsePage or StartBrowser)
-3
Bad descriptor, invalid syntax
-4
The browser has been lost (for instance because of a Closewindow)
-5
Page not found
-8
Specified element not found
-12
Download timeout (the file could not be saved within the #ActionTimeout time)
-11
Any other error
-404,405
Usual http error codes (requires IE 6 or above)
Remarks
If only the path is specified, the file is saved using the name provided by the web page. If the specified directory does not exist, it is created.
At replay, the function waits for the HTML element to be displayed before saving the picture. The timeout is the value of #ActionTimeout (the default is 30 seconds).
Example
On WinTask Web site, we save the image displaying WinTask books:
StartBrowser("IE","www.wintask.com")
UsePage("WinTask - Automation software and Task Scheduler. Macro software with Macro Recorder")
SavePictureAs("IMG[SRC= 'http://www.wintask.com/images/p']", "c:\test")
CloseBrowser()
The image is saved under c:\test with the name pic_wintask_books.jpg which is the original filename of the HTML element.