Jump to content
pdark1987

_ScreenCapture_SaveImage help saving image

Recommended Posts

ss()
Func ss()
    Local $hBmp
 
    ; Capture full screen
    $hBmp = _ScreenCapture_Capture("")
 
    ; Save bitmap to file
    _ScreenCapture_SaveImage(@MyDocumentsDir & "Image.jpg", $hBmp)
 
    ShellExecute(@MyDocumentsDir & "Image.jpg")
EndFunc   ;==>ss
 
 
so the code works my problem is it override the image and i want to rather save it as image1,image2 and so on. and also im not sure how to i can add a folder to it so atm is saving in mydoucments how would i save to a new folder in doc?
thanks for the help

Share this post


Link to post
Share on other sites

Here is how to add a new folder:

_ScreenCapture_SaveImage(@MyDocumentsDir & "\new_folder\Image.jpg", $hBmp)

And to change the name each time I usually use one of the Time Macros.

Share this post


Link to post
Share on other sites

Turns out you have to use DirCreate to add a new folder, this should work

#include <ScreenCapture.au3>

DirCreate(@MyDocumentsDir & "\newfolder\")

ss()
Func ss()
    Local $dTimeStamp = @HOUR & @MIN & @SEC
    Local $hBmp

    ; Capture full screen
    $hBmp = _ScreenCapture_Capture("")

    ; Save bitmap to file
    _ScreenCapture_SaveImage(@MyDocumentsDir & "\newfolder\" &  $dTimeStamp & "Image.jpg", $hBmp)

    ShellExecute(@MyDocumentsDir & "\newfolder\"  & $dTimeStamp & "Image.jpg")
EndFunc   ;==>ss
Edited by l3ill

Share this post


Link to post
Share on other sites

I would go with how Bill has it w/ timestamps (thats how I do it) but if you want a more traditional Image1, Image2, Etc FileListToArray() would work great.

https://www.autoitscript.com/autoit3/docs/libfunctions/_FileListToArray.htm

My concern would be removing images and changing the count so that you end up with duplicates again so in that case I would probably put a date of sorts on my directory instead (by day)

So file structure would be My Documents --> Images --> Folder w/ Date --> Image1, Image2, Image3 Etc.

I created this so users could archive all the scans they get in a single folder, it uses both filelisttoarray and macros to give uniqe names so maybe it will be of help.

;Needed UDFS
#Include <_Zip.au3>
#include <File.au3>
#include <Array.au3>

;Path Varibles
$ArchiveSorc = @ScriptDir
$ArchiveDest = "H:\Scans Archive\"
$ArchiveTmp = @MyDocumentsDir & "\DailyArchive\"

;Msgbox Confirmation 6= Yes Else Exit
$Choice = MsgBox(4, "Black Magic Archive Tool", "Are you ready to archive all .PDF files from your Local Scans folder to your Archive Folder?")
If $Choice = 6 Then

DirCreate($ArchiveDest)
;File Move 9 = Overwrite
FileMove($ArchiveSorc & "\*.pdf", $ArchiveTmp, 9)
;ZipCreate 0 Do not Overwrite
$ZipNow = _Zip_Create($ArchiveDest & @MON & "-" & @MDAY & "-" & @YEAR & " Archive.zip", 0)
If @Error = 1 Then $ZipNow = $ArchiveDest & @MON & "-" & @MDAY & "-" & @YEAR & " Archive.zip"
;@Error 1 = File Already Exsists

;Puts all file names into an Array
$FileList = _FileListToArray($ArchiveTmp)

; Debugging See the Array Values In Window
;_ArrayDisplay($FileList)

For $i = 1 To UBound($FileList) - 1
    ;Debugging See the Current i and array value used in loop
    ;MsgBox(0, "", "Current i Value " & $i & " making current array value" & $FileList[$i])
_Zip_AddItem($ZipNow, $ArchiveTmp & $FileList[$i])

Next

;Delete Temp Folder to keep Computer HDD Clean and Purge Files
FileDelete($ArchiveTmp)
MsgBox(0, "Black Magic Archive Tool", _Zip_Count($ZipNow) & " Items are now in your .ZIP Archive located at " & $ArchiveDest)
Exit

Else
    Exit
EndIf
Edited by ViciousXUSMC

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

×
×
  • Create New...