Sign in to follow this  
Followers 0
icadea

Ghost image file saved

6 posts in this topic

This is one the HELP file examples in AUTO3LIB under _GDIP_ImageSaveToFile

#include <A3LGDIPlus.au3>
#include <A3LScreenCap.au3>

Global $hBitmap1, $hBitmap2, $hImage1, $hImage2

; Initialize GDI+ library
_GDIP_Startup()

; Capture full screen
$hBitmap1 = _ScreenCap_Capture("")
$hImage1  = _GDIP_BitmapCreateFromHBITMAP($hBitmap1)

; Save resultant image
_GDIP_ImageSaveToFile($hImage1, FileSaveDialog("Choose a name.", @ScriptDir, "all (*.*)", 18) & ".jpg")

; Clean up resources
_GDIP_ImageDispose($hImage1)
_GDIP_ImageDispose($hImage2)
_API_DeleteObject($hBitmap1)
_API_DeleteObject($hBitmap2)

; Shut down GDI+ library
_GDIP_ShutDown()

When I insert the FileSaveDialog inside _GDIP_ImageSaveToFile, the program will prompt for location and filename to save. A filename is given and the SAVE button is pressed. The SAVED given filename is shown on the location.

The problem is, if I were to press Cancel or ESC button on the FileSaveDialog, a NONAME jpg file is saved on the compiled program directory.

How do i eliminate this? Please help by showing if i miss any code lines.

thanks.

Share this post


Link to post
Share on other sites



Well for the obvious answer, if you wrap a function call within another function, you are not going to get the function call's (in this case FileSaveDialog) error flag unless the function you are calling has made account for it (which is doubtful, as many don't nest their functions).

So the obvious answer:

$sFSD = FileSaveDialog("Choose a name.", @ScriptDir, "all (*.*)", 18)
If @error Then Exit
_GDIP_ImageSaveToFile($hImage1, $sFSD & ".jpg")

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Share this post


Link to post
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
Sign in to follow this  
Followers 0