Revision: 2944
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at May 15, 2007 11:39 by gtcaz
Initial Code
#!c:/ruby/bin/rubyw.exe
require 'win32ole'
require 'timeout'
filename = ENV['TM_FILEPATH'].chomp.gsub(/\\/, '/').capitalize
url = "file:///" + filename
# Methods
def openNewBrowser(url)
begin
Timeout::timeout(5) {
ie = WIN32OLE.new('InternetExplorer.Application')
ie.Navigate("#{url}")
sleep('.2'.to_f) while ie.ReadyState != 4
ie.Visible = 'true'
}
rescue Timeout::Error
puts "Unable connect to #{url} in a reasonable time"
end
end
def refreshIfOpen(url)
shell = WIN32OLE.new('Shell.Application')
shell.Windows.each do | window |
if window.LocationUrl == "#{url}"
window.refresh()
return true
end
end
return false
end
# Main
unless refreshIfOpen(url)
openNewBrowser(url)
end
Initial URL
Initial Description
Initial Title
Preview in IE command (Windows native version)
Initial Tags
command, textmate
Initial Language
Ruby