Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
スクリーンキャプチャ
class Capture
attr_accessor :path
@@INTERVAL = 30
def initialize(path="~/")
@path = path
end
public
def capture
Dir.glob(@path + "**/*") do | f |
p f
File.delete(f)
end
0.upto(0/(0.0)) do | count |
filename = @path + now() + "-%08d.png"%[count]
save(filename)
sleep(@@INTERVAL)
end
end
private
def save(filename)
system("screencapture -x #{filename}")
end
def now
Time.now.strftime("%Y-%m-%d")
end
end
capture = Capture.new("/Users/hisamatsu/capture/image/")
capture.capture
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment