Skip to content

Instantly share code, notes, and snippets.

@winhelponline
Last active August 16, 2025 09:57
Show Gist options
  • Select an option

  • Save winhelponline/ea605151dd2b1e8a7efdc8e64e2f9a8b to your computer and use it in GitHub Desktop.

Select an option

Save winhelponline/ea605151dd2b1e8a7efdc8e64e2f9a8b to your computer and use it in GitHub Desktop.
Take a screenshot and open it in image editor
'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, Windows 10 and Windows 11.
'Revised on August 16, 2025
Option Explicit
Const CSIDL_MYPICTURES = &H27
Dim fNewest, WshShell, fso, objShell, objFolder, objFolderItem
Dim SShots, f
Set WshShell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(CSIDL_MYPICTURES)
Set objFolderItem = objFolder.Self
SShots = objFolderItem.Path & "\Screenshots"
'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
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