jarmo / RAutomation

RAutomation
MIT License
100 stars 33 forks source link

UIA MenuItem Support #35

Closed leviwilson closed 11 years ago

leviwilson commented 11 years ago

Added support to be able to select menu items when using the ms_uia adapter.

Example

window = RAutomation::Window.new(:title => /SomeWindow/, :adapter => :ms_uia)

# will select File -> Recent Files -> 1.) last_file.txt
window.select_menu_item "File", "Recent Files", "1.) last_file.txt"
jarmo commented 11 years ago

The proposed API seems cumbersome, e.g. it does not follow RAutomation API style. I'm not sure if it is possible technically, but it could be something like this:

window.menu(:text => "File").menu(:text => "Recent Files").menu(:text => "1.) last_file.txt").open
window.menu(:text => "File").menus.map(&:text) # => ["About", "Recent Files", ...]
window.menu(:text => "File").exists? # => true

In other words, menu should be just another control and have the same API like every other control + some method like my proposed #open to finally select that menu item. Or maybe the method name should be #select instead? Otherwise good idea to support menu items too.

What do you think about my ideas?

leviwilson commented 11 years ago

I like it. I'll refactor to be consistent with the api later today. On Nov 11, 2012 10:35 AM, "Jarmo Pertman" notifications@github.com wrote:

The proposed API seems cumbersome, e.g. it does not follow RAutomation API style. I'm not sure if it is possible technically, but it could be something like this:

window.menu(:text => "File").menu(:text => "Recent Files").menu(:text => "1.) last_file.txt").open window.menu(:text => "File").menus.map(&:text) # => ["About", "Recent Files", ...] window.menu(:text => "File").exists? # => true

In other words, menu should be just another control and have the same API like every other control + some method like my proposed #open to finally select that menu item. Or maybe the method name should be #selectinstead? Otherwise good idea to support menu items too.

What do you think about my ideas?

— Reply to this email directly or view it on GitHubhttps://github.com/jarmo/RAutomation/pull/35#issuecomment-10268371.

leviwilson commented 11 years ago

Refactored to include all of your suggestions. Let me know if this will work.