-
-
Save winhelponline/ea605151dd2b1e8a7efdc8e64e2f9a8b to your computer and use it in GitHub Desktop.
Take a screenshot and open it in image editor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'Ramesh Srinivasan, Winhelponline.com | |
'Take a screenshot and open it in image editor | |
'Requires NirCmd.exe (from www.nirsoft.net) to automate Win + PrntScrn | |
'For Windows 8 and Windows 10. | |
Set WshShell = CreateObject("WScript.Shell") | |
Set fso = CreateObject("Scripting.FileSystemObject") | |
'Sleep for 2 seconds until the user sets the active Window or menu | |
WScript.Sleep 2000 | |
'Take full screenshot | |
WshShell.Run "nircmd.exe " & "sendkeypress rwin+printscreen" | |
'Sleep again for half a second - wait until the PNG file is written | |
WScript.Sleep 500 | |
Dim fNewest | |
'Find the latest PNG file in Screenshots folder and Open it in editor. | |
SShots = WshShell.ExpandEnvironmentStrings("%userprofile%") | |
SShots = SShots & "\Pictures\Screenshots" | |
If Not fso.FolderExists(SShots) Then WScript.Quit | |
For Each f In fso.GetFolder(SShots).Files | |
If UCase(fso.GetExtensionName(f)) = "PNG" Then | |
If fNewest = "" Then | |
Set fNewest = f | |
ElseIf fNewest.DateLastModified < f.DateLastModified Then | |
Set fNewest = f | |
End If | |
End If | |
Next | |
If fNewest <> "" Then WshShell.Run "mspaint.exe " & Chr(34) & fNewest & Chr(34) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment