It would be nice if on any class you could have read only access to the hwnd property of that control. This became a priority for me when I needed to recursively loop through tabs on an application, that is the main window is a tabbed window but each tab may contain additional tabs. To keep track of tabs visited I wanted to push their unique identifier to an array like this:
def loop_tabs(visited=[])
i = 0
while( tab_control = @window.tab_control( :index => i ) ) && tab_control.exists?
tab_control.items.each do |tab|
if item.selected?
visited.push(item.hwnd)
end
item.select unless visited.includes? item.hwnd
loop_tabs visted
end
i += 1
end
end
I tried to monkey patch the TabItem class like so
module RAutomation
module Adapter
module MsUia
class TabControl
class TabItem
attr_reader :hwnd
end
end
end
end
end
But upon careful inspection I realized that the TabItem class doesn't even hold a @hwnd variable.
It would be nice if on any class you could have read only access to the hwnd property of that control. This became a priority for me when I needed to recursively loop through tabs on an application, that is the main window is a tabbed window but each tab may contain additional tabs. To keep track of tabs visited I wanted to push their unique identifier to an array like this:
I tried to monkey patch the TabItem class like so
But upon careful inspection I realized that the TabItem class doesn't even hold a
@hwnd
variable.