Skip to content

Instantly share code, notes, and snippets.

@hisasann
Created January 25, 2013 09:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hisasann/4633009 to your computer and use it in GitHub Desktop.
Save hisasann/4633009 to your computer and use it in GitHub Desktop.
スクリーンキャプチャ
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