Script to take screenshots of VirtualBox VMs

Here’s an AutoHotKey script to take screenshots of Oracle VirtualBox VMs. The script takes a screenshot, saves it to your disk and places the image on your clipboard.

It uses IrfanView (free) to put the image on the clipboard. It assumes the path to i_view32, IrfanView’s main executable, is on your path.

F10 is the key to create the screenshot.


#SingleInstance, Force
#Persistent
SetTitleMatchMode, 2

Loc=D:\Desktop\Screenshots

*F10::
WinActivate, [Running] - Oracle VM VirtualBox

;Get VM name
WinGetTitle, VmName, [Running] - Oracle VM VirtualBox
StringReplace, VmName, VmName, [Running] - Oracle VM VirtualBox
FileName=%Loc%\%VmName%-%A_Hour%-%A_Min%_%A_Sec%.png

;Take screenshot
SendInput, {RCtrl Down}e{RCtrl Up}
WinWaitActive, Select a filename for the screenshot
SendInput, %FileName%{enter}
WinWaitClose, Select a filename for the screenshot

;Copy screenshot to clipboard
Run, i_view32.exe %FileName% /clipcopy /killmesoftly

Return

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.