aa2zz6 Posted October 1, 2015 Share Posted October 1, 2015 (edited) I'm writing this script for my parent who is less tech savvy. For the work she does sometimes the website gets glitched and she has to take print screens and then email. I was wondering if it was possible to have the print screen save as the current date. I've used the _NowDate for many of my projects but I wasn't able to figure it out. #include <ScreenCapture.au3> #include<Date.au3> HotKeySet("{PRINTSCREEN}", "printscreen") While 1 Sleep(100) WEnd Func printscreen() _ScreenCapture_Capture(@DesktopDir & "\picture.jpg") EndFunc Edited October 1, 2015 by aa2zz6 Link to comment Share on other sites More sharing options...
Danyfirex Posted October 1, 2015 Share Posted October 1, 2015 You can do this. StringReplace(_NowDate(),"/","-") Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
ahmeddzcom Posted October 1, 2015 Share Posted October 1, 2015 (edited) Hello#include <File.au3> #include <ScreenCapture.au3> HotKeySet("{PRINTSCREEN}", "printscreen") While 1 Sleep(100) WEnd Func printscreen() $FilePath =(@DesktopDir&"/") $FileName = 'Vv' $FileList = _FileListToArray($FilePath, $FileName & '*.jpg', 1) If Not IsArray($FileList) Then $FileName&= '1.jpg' Else $FileName &= $FileList[0] + 1 & '.jpg' EndIf _ScreenCapture_Capture($FilePath & "\" & $FileName) EndFunc Edited October 1, 2015 by ahmeddzcom Link to comment Share on other sites More sharing options...
aa2zz6 Posted October 1, 2015 Author Share Posted October 1, 2015 (edited) Thanks for the advice guys, the working code will be listed below.#include <ScreenCapture.au3> #include<Date.au3> #include <MsgBoxConstants.au3> HotKeySet("{PRINTSCREEN}", "prtSc") Local $sString = StringReplace(_NowDate(),"/","-") While 1 Sleep(100) WEnd Func prtSc() _ScreenCapture_Capture(@DesktopDir & "\" & $sString & ".jpg") EndFunc Edited October 1, 2015 by aa2zz6 Revised code! Link to comment Share on other sites More sharing options...
kylomas Posted October 1, 2015 Share Posted October 1, 2015 aa2zz6,If you wanted to include the time (multiple copies per day) you could do something like this...#include <ScreenCapture.au3> #include <Date.au3> #include <MsgBoxConstants.au3> HotKeySet("{PRINTSCREEN}", "prtSc") Local $sString = StringReplace(_NowDate(), "/", "-") While 1 Sleep(100) WEnd Func prtSc() _ScreenCapture_Capture(@DesktopDir & "\" & StringRegExpReplace(_Now(), '[/ :]', '-') & ".jpg") EndFunc ;==>prtSckylomas aa2zz6 1 Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
aa2zz6 Posted October 1, 2015 Author Share Posted October 1, 2015 Thanks kylomas, I was planning to look at ahmeddzcom code tomorrow after work and see how I could go about creating multiple images. I do appreciate the help from everyone! Link to comment Share on other sites More sharing options...
UEZ Posted October 1, 2015 Share Posted October 1, 2015 You can save also the bitmap from the clipboard:#include <Clipboard.au3> #include <GDIPlus.au3> _GDIPlus_Startup() Send("{PRINTSCREEN}") Sleep(100) ConsoleWrite(_GDIPlus_ImageSaveClipboardToFile(@ScriptDir & "\" & @YEAR & @MON & @MDAY & "_" & @HOUR & @MIN & @SEC & "_Test.jpg") & "/" & @error & @CRLF) _GDIPlus_Shutdown() Func _GDIPlus_ImageSaveClipboardToFile($sFilename) ;coded by UEZ build 2015-10-01 If Not _ClipBoard_Open(0) Then Return SetError(1, 0, 0) Local Const $hMemoryBMP = _ClipBoard_GetDataEx($CF_BITMAP) If Not $hMemoryBMP Then _ClipBoard_Close() Return SetError(2, 0, 0) EndIf Local Const $hBmp = _GDIPlus_BitmapCreateFromHBITMAP($hMemoryBMP) _ClipBoard_Close() _WinAPI_DeleteObject($hMemoryBMP) If Not _GDIPlus_ImageSaveToFile($hBmp, $sFilename) Then _GDIPlus_BitmapDispose($hBmp) Return SetError(3, 0, 0) EndIf _GDIPlus_BitmapDispose($hBmp) Return 1 EndFunc aa2zz6 1 Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now