Sha256: 667366cf9529ac1fa2ce514795b9f0e0de2cb5385dbc6861b30e98edcdad84d8
Contents?: true
Size: 1.34 KB
Versions: 2
Compression:
Stored size: 1.34 KB
Contents
module WinCI module Updater def message_box(txt, title='Ruby', buttons=MB_OK | MB_SETFOREGROUND) user32 = DL.dlopen('user32') msgbox = user32['MessageBoxA', 'ILSSI'] r, rs = msgbox.call(0, txt, title, buttons) return r end def inputbox(message, title="Message from #{__FILE__}") # returns nil if 'cancel' is clicked # returns a (possibly empty) string otherwise require 'win32ole' # hammer the arguments to vb-script style vb_msg = %Q| "#{message.gsub("\n", '"& vbcrlf &"')}"| vb_msg.gsub!("\t", '"& vbtab &"') vb_msg.gsub!('&""&', '&') vb_title = %Q|"#{title}"| # go! sc = WIN32OLE.new("ScriptControl") sc.language = "VBScript" sc.eval(%Q|Inputbox(#{vb_msg}, #{vb_title})|) end def popup(message) require 'win32ole' wsh = WIN32OLE.new('WScript.Shell') wsh.popup(message, 0, __FILE__) end def prompt_user(msgRequest, msgWrong) answer = '' # prompt user to select destination installation disk i = 0 begin puts msgWrong if i > 0 answer = inputbox msgRequest exit if not answer answer = answer.upcase[0].chr if answer.length > 0 i = i + 1 end while !answer or (answer !~ /\A[A-Z]\Z/) answer end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
winci-updater-0.0.2 | lib/winci-updater/gui.rb |
winci-updater-0.0.1 | lib/winci-updater/gui.rb |