Computer >> Hướng Dẫn Máy Tính >  >> Phần Mềm >> Máy Ảo

Hướng dẫn từng bước: Chụp ảnh màn hình trong VirtualBox như Pro

Hot topic. Bạn thực hiện cài đặt/operations trong VM dùng VirtualBox, muốn screenshot document hoạt động. Trong VMware range, screenshot feature có trong system menu, rất simple. VirtualBox: KHÔNG có option đó. Phải dùng host utilities: screenshot programs, PrtScrn, Alt+PrtScrn, key combos. Không luôn simple, biggest problem: VirtualBox treat part of interface as guest OS screen space. Screenshot không bao giờ clean.

Problem rõ ràng: muốn screenshot guest systems từ ngoài, không share folders copy/paste screenshot từ trong VM ra host. Muốn functionality trên host chụp screenshot, exclude inner VirtualBox border. Có thể? Yes, từ version 4.0. Follow me.

Screenshots, today

Dùng SnagIt, IrfanView, GIMP, Gnome Screenshot, KSnapshot... kết quả luôn same. Annoying top/bottom border cho thấy bạn screenshot VirtualBox window. Ví dụ:

Annoying. Chỉ muốn blue rectangle, phải manually crop, waste time. Simple alternative: dùng VirtualBox command line.

Solution: Dùng VBoxManage từ commandline

Feature mới version 4.0+, không work older editions. Chạy lệnh:

VBoxManage controlvm <vm name> screenshotpng <filename>.png

Đó là tất cả magic, <vm name> tên VM, <filename> string bất kỳ identify screenshots sau. Ubuntu Lucid example:

Scripting

Vẫn partly automate, không phải luôn manual command line. Tạo scripts execute command. Demo BASIC (BAT) Windows và BASH Linux. Dùng generic identifiers cho images, không cần manual input names mỗi lần. Environment variable RANDOM hoặc time stamp là good options. Tạo shortcuts trên desktop/app panels, add hotkey combos invoke shortcuts/apps.

Windows example

Command line Windows không natural nhưng dễ. Master basics [sic], move to batch files.

Hardcode image names hoặc tạo unique strings: time/date string hoặc random number. Viết simple batch file execute command.

echo off
<full path to VBoxManage.exe" controlvm <vm name> screenshotpng <filename>.png

Cụ thể, example Windows 8 guest. Tạo batch file cho VM, append random string vào image names để unique. Đặt images trong Share directory, nhưng dùng gì cũng được. VM name hardcoded hoặc input argument.

echo off
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" controlvm Windows-8 screenshotpng C:\Share\image-%random%.png

Tạo shortcut, đặt đâu đó, edit properties, add shortcut key combo invoke it. Làm việc dễ và nhanh hơn.

Linux example

Linux dễ hơn.

Tạo script simple chỉ một dòng.

#!/bin/bash
VBoxManage controlvm <vm name> screenshotpng ~/image-`date +%s`.png
exit 0

Kết quả: images home directory, elapsed seconds since 1970 appended. Hardcode VM name trong script hoặc pass as input argument (yêu cầu interaction). Hoặc parse process table tìm tên running VM container cho fully unattended script. Dùng which detect full path VBoxManage binary.

Tạo shortcuts. Ví dụ Gnome: add custom launcher top panel, command field viết full path screenshot script. Automated solution gần equivalent execute menu option, thậm chí faster. Many options, này get you started.

Another advantage

Method này có bonus external utilities không có. Grab contents entire screen guest, ngay cả khi chỉ partially shown trên host monitor. Nếu khác resolution host/guest, multiple monitors hoặc windowed, không annoying cropping. Ví dụ Windows 8 VM: thấy horizontal/vertical scroll bars? Nghĩa là không thấy tất cả, nhưng screenshot capture feature giải quyết.

Kết luận

Xong. Bạn học cách bypass annoying thing VirtualBox: manage VM screenshots. Với command line, almost 100% automate screenshot taking.

Tutorial focus VirtualBox và screenshots, nhưng cũng dạy lateral thinking, expose VirtualBox powerful command line management, dùng scripts, shortcuts, shortcut combo keys làm life easier, cả Windows và Linux, BASIC, BASH, works fine. Hope you liked it, have fun.

Cheers.