In vbscript it is common to use the browser (IE) as a GUI. See the example below, it asks for a name and returns it to the script. In Ruby you have a few GUI\'s like Tcl and
win32ole is already mentioned.
Here an example script:
require 'win32ole'
def inputbox( message, title="Message from #{__FILE__}" )
# returns nil if 'cancel' is clicked
# returns a (possibly empty) string otherwise
# 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})|)
#~ sc.eval(%Q|Inputbox(#{vb_msg}, #{vb_title}, aa,hide)|)
end
#simple use
res = inputbox "Your input please."
p res
To give a message box you may use:
require 'win32ole'
def popup(message)
wsh = WIN32OLE.new('WScript.Shell')
wsh.popup(message, 0, __FILE__)
end
In http://rubyonwindows.blogspot.com/2007/04/ruby-excel-inputbox-hack.html (source of this examples) you find also a solution with Excel.