Jump to content

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


caiolps
 Share

Recommended Posts

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.

Link to comment
Share on other sites

  • Moderators

@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.

 

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
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?

Link to comment
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

 

Link to comment
Share on other sites

  • 2 weeks later...

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...