How to Automatically Take a Screenshot and Open it in a Editor?

Using the WinKey and Prnt Scrn keystroke is probably the fastest way to take a full screenshot and automatically save it to a file, in Windows 8 and higher. When using this method, the screenshot image contains your entire screen including the Taskbar and everything. And in most cases you may have to crop the image before sending or sharing it with someone, so that only the relevant portion is shown.

automatically take screenshot and editor

Alt + PrintScreen can capture the current window but doesn’t save to a file automatically and it can’t capture context menus — so it’s not always the desired option. Personally, I prefer the following script method to Alt + PrintScreen or Snipping Tool when I’m not using a 3rd party screenshot utility.

Using Script to Take Screenshot and Open it in Editor

Here is a script that automates the task of taking a full screenshot using NirCmd and opening the saved PNG file in image editor. You can then crop the image and save the file.

'Ramesh Srinivasan, Winhelponline.com
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 fso.FolderExists(SShots) then
	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)
End If

Usage

  • Download NirCmd (from NirSoft) and move the executable to your Windows folder.
  • Copy the above lines to Notepad and save it with .vbs extension.
  • Create a desktop shortcut to the .vbs (script file), change the shortcut icon and and Pin it to Taskbar.

When a script is used to trigger WinKey + PrintScreen key sequence, the window focus would change (which is not the case when pressing WinKey + PrintScreen manually).

Due to this, your program window would show up with inactive title bar color in the screenshot. To avoid that, the script is set to wait for 2 seconds after it’s being launched, and then simulates the key press event. In the mean time the user can set the focus back to the appropriate window. The timeout can also be useful if you want to capture a context menu.

Using ShareX to Take Screenshot and Open it in Editor

ShareX is a very useful screenshot utility which has some advanced options such as uploading the captured image to your cloud storage account, or sharing the link in social networking sites etc. In ShareX you can configure "after capture" tasks and create task actions which would be carried out automatically.

Set the After capture tasks to "Perform actions"

automatic screenshot and open in editor

And in the Task Settings, enable the checkbox for Paint or any image editor you use. If your image editor isn’t listed, you can add one manually.

automatic screenshot and open in editor

Related article

How to Take a Screenshot in Windows? Different Ways Explained » Winhelponline

About the author

Ramesh Srinivasan founded Winhelponline.com back in 2005. He is passionate about Microsoft technologies and has a vast experience in the ITeS industry — delivering support for Microsoft's consumer products. He has been a Microsoft MVP [2003 to 2012] who contributes to various Windows support forums.