Screen Shot - Ruby
Hiroto,
Awhile back you posted this script, but no longer works with Yosemite, can you post the needed edit?
#!/bin/bash
# screenshot area
x=0
y=0
w=$((1365-$x))
h=$((767-$y))
OSXver=$(sw_vers -productVersion)
if [[ $OSXver < "10.9" ]]; then
ruby="/usr/bin/ruby"
else
ruby="/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby"
fi
$ruby <<-'END' - "$x" "$y" "$w" "$h"
require 'osx/cocoa'
include OSX
raise ArgumentError, "Usage: #{File.basename($0)} x, y, w, h" unless ARGV.length == 4
x, y, w, h = ARGV.map {|a| a.to_f}
outfile = File.expand_path(%x[date +'%F %H.%M.%S.png'].chomp, '~/Desktop')
img = CGDisplayCreateImageForRect(CGMainDisplayID(), CGRectMake(x, y, w, h))
brep = NSBitmapImageRep.alloc.initWithCGImage(img)
data = brep.objc_send(
:representationUsingType, NSPNGFileType,
:properties, {})
data.objc_send(
:writeToFile, outfile,
:atomically, false)
END
OS X Yosemite (10.10)