Skip to content

Instantly share code, notes, and snippets.

@raa0121
Last active December 14, 2015 03:09
Show Gist options
  • Save raa0121/5018589 to your computer and use it in GitHub Desktop.
Save raa0121/5018589 to your computer and use it in GitHub Desktop.

autoUpload.rb

Minecraftのスクリーンショットをローカルに保存したらgyazoに投稿するためのスクリプト

使い方

Windowsの場合

gyazo_pathを変更の上、

gem install win32-event win32-changenotify
rubyw autoUpload.rb

Linux,Macの場合

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment