Minecraftのスクリーンショットをローカルに保存したらgyazoに投稿するためのスクリプト
gyazo_pathを変更の上、
gem install win32-event win32-changenotify
rubyw autoUpload.rb
gyazo_pathを変更の上、
gem install fssm
ruby autoUpload.rb &
#!/usr/bin/env ruby | |
# -*- coding : utf-8 -*- | |
gyazo_path = "D:/Program/gyazo_cre/gyazowin+.exe" | |
screenshots = "" | |
require "rbconfig" | |
osn = RbConfig::CONFIG["target_os"].downcase | |
if osn =~ /mswin(?!ce)|mingw|cygwin|bccwin/ | |
os = "win" | |
screenshots = "#{ENV['APPDATA']}\\.minecraft\\screenshots" | |
elsif osn =~ /linux/ | |
screenshots = "#{ENV['HOME']}/.minecraft/screenshots" | |
elsif osn =~ /darwin/ | |
screenshots = "#{ENV['HOME']}/Library/Application Support/minecraft/screenshots" | |
end | |
if os == "win" | |
require 'win32/changenotify' | |
include Win32 | |
filter = ChangeNotify::FILE_NAME | ChangeNotify::DIR_NAME | |
cn = ChangeNotify.new(screenshots, true, filter) | |
cn.wait do |e| | |
e.each do |i| | |
if i.action == "added" | |
`#{gyazo_path} #{i.file_name}` | |
end | |
end | |
end | |
else | |
require 'fssm' | |
notifier = FSSM.new | |
notifier.monitor(screenshots, '**/*.png') do | |
create do |base,file| | |
`#{gyazo_path} #{base}/#{file.name}` | |
end | |
end | |
end |