gouf
12/2/2013 - 3:33 AM

筆圧検知が有効になったら(ペンタブのドライバが起動したら) SAI を起動する。

筆圧検知が有効になったら(ペンタブのドライバが起動したら) SAI を起動する。

require 'win32ole'

# Description: Running sai.exe when enabled pen pressure detection on startup.
# Ref: 
# http://ossan78.blog9.fc2.com/blog-entry-3.html
# http://oshiete.goo.ne.jp/qa/1758020.html at No.2, BLUEPIXY's answer.

SAI_PATH = 'C:\PaintToolSAI\sai.exe'

def prList
	pr = WIN32OLE.connect('winmgmts:').InstancesOf('Win32_process')
	pr.each.map{|x| x.name}.to_a
end

def prRun? str
	prList.select{|x| x == str}.size != 0
end


loop do
	pr = prList
	break if prRun? 'Wacom_Tablet.exe'
	puts 'wating for start up Wacom Tablet Driver... (3 sec.)'
	sleep 3
end

unless prRun? 'sai.exe'
	shell = WIN32OLE.new("WScript.Shell")
	shell.Run(SAI_PATH)
end

puts 'sai.exe has started.' if prRun? 'sai.exe'
sleep 1
@ECHO OFF
REM Determine where is RUBY_BIN (where this script is)
PUSHD %~dp0.
SET RUBY_BIN=%CD%
POPD

REM Add RUBY_BIN to the PATH
REM RUBY_BIN takes higher priority to avoid other tools
REM conflict with our own (mainly the DevKit)
SET PATH=%RUBY_BIN%;%PATH%
SET RUBY_BIN=

REM Display Ruby version
ruby.exe -v

REM add description below:
ruby "C:\Users\user_name\sai_startup.rb"