Sunday, November 29, 2009

How to select ComboBox

How to select ComboBox by AutoIt.exe from ruby
Give parameter to select combobox exe.


### select_year_combobox.au3 ###
WinActivate("Configuration")
Global Const $CB_SETCURSEL = 0x14E
$h_combobox = ControlGetHandle("Configuration", "", "[CLASS:WindowsForms10.COMBOBOX.app.0.378734a; INSTANCE:2]")
$i_index = $CMDLINE[1]
DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_combobox, "int", $CB_SETCURSEL, "int", $i_index, "int", 0)


ControlGetHandle("Configuration", "", "[CLASS:WindowsForms10.COMBOBOX.app.0.378734a; INSTANCE:2]")
ControlGetHandle(<app title>, "", <select combobox instance>).
<select combobox instance> is easy to know by AutoIt Window Info app.


### select_combobox.rb ###
select_year_exe = File.expand_path(File.dirname(__FILE__) + "/select_year_combobox.exe")
year = 1 # ex. index 1 = 2005
system("#{select_year_exe} #{year}")


>ruby select_combobox.rb # app will choose index 1 from combobox.
>select_year_combobox.exe 1 # app will choose index 1 from combobox.

No comments:

Post a Comment