Changeset 24450 in vbox
- Timestamp:
- Nov 6, 2009 3:33:38 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 54515
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxShell/vboxshell.py
r23994 r24450 334 334 vbox.unregisterCallback(cb) 335 335 336 337 def takeScreenshot(ctx,console,args): 338 from PIL import Image 339 display = console.display 340 if len(args) > 0: 341 f = args[0] 342 else: 343 f = "/tmp/screenshot.png" 344 if len(args) > 1: 345 w = args[1] 346 else: 347 w = console.display.width 348 if len(args) > 2: 349 h = args[2] 350 else: 351 h = console.display.height 352 print "Saving screenshot (%d x %d) in %s..." %(w,h,f) 353 data = display.takeScreenShotSlow(w,h) 354 size = (w,h) 355 mode = "RGBA" 356 im = Image.frombuffer(mode, size, data, "raw", mode, 0, 1) 357 im.save(f, "PNG") 358 359 336 360 def cmdExistingVm(ctx,mach,cmd,args): 337 361 mgr=ctx['mgr'] … … 362 386 'guest': lambda: guestExec(ctx, mach, console, args), 363 387 'monitorGuest': lambda: monitorGuest(ctx, mach, console, args), 364 'save': lambda: progressBar(ctx,console.saveState()) 388 'save': lambda: progressBar(ctx,console.saveState()), 389 'screenshot': lambda: takeScreenshot(ctx,console,args) 365 390 } 366 391 try: … … 614 639 return 0 615 640 cmdExistingVm(ctx, mach, 'guest', ' '.join(args[2:])) 641 return 0 642 643 def screenshotCmd(ctx, args): 644 if (len(args) < 3): 645 print "usage: screenshot name file <width> <height>" 646 return 0 647 mach = argsToMach(ctx,args) 648 if mach == None: 649 return 0 650 cmdExistingVm(ctx, mach, 'screenshot', args[2:]) 616 651 return 0 617 652 … … 971 1006 'sleep':['Sleep for specified number of seconds: sleep 3.14159', sleepCmd, 0], 972 1007 'shell':['Execute external shell command: shell "ls /etc/rc*"', shellCmd, 0], 973 'exportVm':['Export VM in OVF format: export Win /tmp/win.ovf', exportVMCmd, 0] 1008 'exportVm':['Export VM in OVF format: export Win /tmp/win.ovf', exportVMCmd, 0], 1009 'screenshot':['Take VM screenshot to a file: screenshot Win /tmp/win.png 1024 768', screenshotCmd, 0] 974 1010 } 975 1011
Note:
See TracChangeset
for help on using the changeset viewer.