Babu16 Posted February 2, 2018 Posted February 2, 2018 Hi All, I've created a folder which has Date time appended (For example - Folder Name 'xxxx-20180202') , i will then open a created folder and Save file, but i'm unable to open a created file with date and time, Please find the following code and request you to help me to fix this. $sFilepath ="C:\projects" $sFilepath1 = $DirCreate($sFilepath &@YEAR &@MON &@MDAY&"-"&@HOUR &@MIN &@SEC) -; Appending time stamp to the folder ;Capture snap shot and save image file in the created folder _ScreenCapture_Capture($sFilepath1 & "\Image01.jpg") ShellExecute($sFilepath1 & "\Image01.jpg") Since $sFilepath1 returning1, i'm unable to open a created file.
Developers Jos Posted February 2, 2018 Developers Posted February 2, 2018 2 minutes ago, Babu16 said: $DirCreate Shouldn't that be without the $ as this is not a variable but a function? Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Babu16 Posted February 2, 2018 Author Posted February 2, 2018 Sorry, that's Typo mistake, corrected $sFilepath1 = DirCreate($sFilepath &@YEAR &@MON &@MDAY&"-"&@HOUR &@MIN &@SEC)
Developers Jos Posted February 2, 2018 Developers Posted February 2, 2018 Ok, so what i the problem with constructing a filename in the same way you construct the directory? What have you tried that isn't working? Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
abdulrahmanok Posted February 2, 2018 Posted February 2, 2018 (edited) sure that's will not working because $sFilepath1 will return 1maybe this will work: #include <ScreenCapture.au3> $sFilepath ="C:\projects" $sFilepath1 = DirCreate($sFilepath &@YEAR &@MON &@MDAY&"-"&@HOUR &@MIN &@SEC) ConsoleWrite($sFilepath1) ConsoleWrite(@CRLF&$sFilepath&@YEAR &@MON &@MDAY&"-"&@HOUR &@MIN &@SEC & "\Image01.jpg") _ScreenCapture_Capture($sFilepath &@YEAR &@MON &@MDAY&"-"&@HOUR &@MIN &@SEC & "\Image01.jpg") ShellExecute($sFilepath &@YEAR &@MON &@MDAY&"-"&@HOUR &@MIN &@SEC & "\Image01.jpg") Edited February 2, 2018 by abdulrahmanok Babu16 1
Babu16 Posted February 2, 2018 Author Posted February 2, 2018 Since this '$sFilepath1' is returning 1, whenever i execute this command ' ShellExecute($sFilepath1 & "\Image01.jpg") ' to save the captured file, i'm getting the error message as Windows can't open a file '1\image01'.
abdulrahmanok Posted February 2, 2018 Posted February 2, 2018 1 minute ago, Babu16 said: Since this '$sFilepath1' is returning 1, whenever i execute this command ' ShellExecute($sFilepath1 & "\Image01.jpg") ' to save the captured file, i'm getting the error message as Windows can't open a file '1\image01'. I edited my previous code try it
Developers Jos Posted February 2, 2018 Developers Posted February 2, 2018 (edited) 5 minutes ago, Babu16 said: Since this '$sFilepath1' is returning 1, whenever i execute this command ' ShellExecute($sFilepath1 & "\Image01.jpg") ' to save the captured file, i'm getting the error message as Windows can't open a file '1\image01'. Why are you expecting DirCreate() to return the full path? It doesn't, but rather a 1 when it was successful and else a 0! Helpfile is your friend! Jos Edited February 2, 2018 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Babu16 Posted February 2, 2018 Author Posted February 2, 2018 Yes, This code is working fine, thank you so much:-) abdulrahmanok 1
Subz Posted February 2, 2018 Posted February 2, 2018 You should probably declare the name Directory and Filename otherwise you may find that it will fail since your using @Sec also not sure if you wanted to create multiple folders (since @Sec would create a new directory each time) you could use something like: C:\Projects\YYYYMMDD\HHMMSS_Image.jpg #include <ScreenCapture.au3> Local $sDirPath ="C:\Projects\" & @YEAR & @MON & @MDAY DirCreate($sDirPath) Local $sFilepath = $sDirPath & "\" & @HOUR & @MIN & @SEC & "_Image.jpg" _ScreenCapture_Capture($sFilepath) ShellExecute($sFilepath)
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