Home > Language Reference > Web Functions > SavePictureAs

SavePictureAs

The SavePictureAs function simulates the browser "Save Picture As" command. SavePictureAs function is not supported with Firefox.

Usage

Used to download and save directly an image instead of right-clicking an image element and selecting Save Picture As command.

Syntax

ret=SavePictureAs(<html_descriptor>, <folder> [, <filename>])

Parameters

<html_descriptor>, string, HTML descriptor of the image element. Use Spy tool for generating the HTML descriptor.

<folder>, string, folder the file is saved in.

<filename>, string, optional, saves under this new filename. 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 filename is created using the url of the picture. If for any reason, a valid name cannot be generated, SavePictureAs generates an automatic filename, bitmapxxxx

Return value

Ret, optional numeric return code. If the function succeeds within the timeout (30 seconds by default or the #ActionTimeout value), the function returns 0. If the file cannot be created, the function returns 26. If the function fails for Internet reasons, the return value is a nonzero negative value (see Web Functions Error Codes).

Remarks

If the specified folder does not exist, it is created.

Examples

'On WinTask Web site, we save the image displaying WinTask books:
StartBrowser("IE","www.wintask.com")
UsePage("Macro and Data Extraction with WinTask - the automation software for Windows and internet")
SavePictureAs("IMG[SRC= 'http://www.wintask.com/images/p']", "c:\wttest","imageproduct")
CloseBrowser()
'The image is saved under name imageproduct.jpg in the c:\wttest folder.


'On WinTask Web site loaded in Firefox, we save the image displaying WinTask books:
StartBrowser("FF","www.wintask.com")
UsePage("Macro and Data Extraction with WinTask - the automation software for Windows and internet")
SavePictureAs("IMG[SRC= 'http://www.wintask.com/images/p']", "c:\wttest","imageproduct")
CloseBrowser()
 'The image is saved under name imageproduct.jpg in the c:\wttest folder.


'On WinTask Web site loaded in Chrome, we save the image displaying WinTask books:
StartBrowser("CH","www.wintask.com")
UsePage("Macro and Data Extraction with WinTask - the automation software for Windows and internet")
SavePictureAs("IMG[SRC= 'http://www.wintask.com/images/p']", "c:\wttest","imageproduct")
CloseBrowser()
'The image is saved under name imageproduct.jpg in the c:\wttest folder.