Sign in to follow this  
Followers 0
caiolps

How can I set to a script insert date and hour in a file?

5 posts in this topic

Hello.

I got a big problema that I tried to solve reading and reading, but I'm a newbie in Autoit.

I got this simple script:

#include <ScreenCapture.au3>
#include <File.au3>

HotKeySet("{PRINTSCREEN}", "SS")

While 1
    Sleep(100)
WEnd

Func SS()
    _ScreenCapture_Capture(@MyDocumentsDir & "\screenshot.jpg")
EndFunc

How can I set to everytime that I press PRINTSCREEN, a new file named with hour and date be created?

 

Thanks in advance.

Share this post


Link to post
Share on other sites



@caiolps didn't read that much did you ;) Look in the help file under Macro Reference; there is a macro for everything you want to do.

 


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Like this?

 

#include <ScreenCapture.au3>
#include <File.au3>

$HMSDMYY = @HOUR & "_" & @MIN & "_" & @sec &"_" & @MDAY & @MON & @year & ".jpg"

HotKeySet("{PRINTSCREEN}", "SS")

While 1
    Sleep(100)
WEnd

Func SS()
    _ScreenCapture_Capture(@MyDocumentsDir & "\screenshot_" & $HMSDMYY)
EndFunc

Added minutes and seconds for in case you want more in the Hour?

1 person likes this

Share this post


Link to post
Share on other sites

And another example that generates unique file names with a format  that chronologically sorts on name.

#include <ScreenCapture.au3>

HotKeySet("{PRINTSCREEN}", "SS")
HotKeySet("{ESC}", "Terminate")

While 1
    Sleep(100)
WEnd

; Can provide 999 unique file names per hour in the format of SCYYYYMMDDHH_001.jpg to SCYYYYMMDDHH_999.jpg
Func SS()
    Local $aFileName, $iCount = 0
    While 1
        $iCount += 1
        $aFileName = @MyDocumentsDir & "\SC" & @YEAR & @MON & @MDAY & @HOUR & _
                     "_" & StringRight("00" & $iCount, 3) & ".jpg"
        If FileExists($aFileName) = 0 Then ExitLoop
    WEnd
    _ScreenCapture_Capture($aFileName)
    ShellExecute($aFileName)
EndFunc   ;==>SS

Func Terminate()
    Exit
EndFunc   ;==>Terminate

 

1 person likes this

Share this post


Link to post
Share on other sites

Thanks to y'all. But a huge thanks to @Malkey for help me with exactly what I've been lookin for.

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