Jump to content

Problem with automating taking a printscreen


Recommended Posts

I wrote a script in AutoIT that should take a printscreen, paste it in MS Paint and automatically save it with the current date and time.

All of the main functionality is working, but the datetime seems to have some inconsistency problems in the formatting. I want the date formatted as DDMMYYYY HHMMSS but i get YYYY HHMMSS and sometimes YYY HHMMSS.

I also have a problem where the save window is opened up again after simulating the Enter keypress. Any ideas about what can be the problem? Below you can find my code.

Thanks in advance for the help.

#include <Constants.au3>
#include <Date.au3>
#Include <WinAPI.au3>
; Script Function:
;   Make a screenshot of the current screen
;


; Prompt the user to run the script.
Local $iAnswer = MsgBox(BitOR($MB_OK, $MB_SYSTEMMODAL), "Screenshot maken", "Zorg dat je op de juiste pagina in TPC bent en druk dan op OK.")

Send("{PRINTSCREEN}")
Run("mspaint")
WinWaitActive("Untitled - Paint")
Send("^v")
ChangeDateFormat()
SaveFile()


Func ChangeDateFormat()
   Global $sDate = _Now()
   Global $sOutput = StringRegExpReplace($sDate, "(?i)[^a-z0-9]", "")
EndFunc

Func SaveFile()
   Send("^s")
   Send($sOutput)
   sleep(500)
   Send("{ENTER}")
EndFunc

; Finished!

 

Edited by Melba23
Added code tags - and moved to correct section
Link to comment
Share on other sites

What about this?

#include <ScreenCapture.au3>

_ScreenCapture_SetJPGQuality(100);max image quality
$scrFile = @DesktopDir & "\screenshot - " & @MDAY & @MON & @YEAR & '-' & @HOUR &@MIN& @SEC & ".bmp"
_ScreenCapture_CaptureWnd($scrFile, "[ACTIVE]", -1, -1, -1, -1, 0)

 

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

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

  • Recently Browsing   0 members

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