jarmo / RAutomation

RAutomation
MIT License
100 stars 33 forks source link

Feature Request: Tab Order #5

Closed myungs closed 12 years ago

myungs commented 13 years ago

It would be nice to be able to grab the tab order property inside an element on the screen.

Either that or be able to see what element is in focus, so while you tab you can check what element is in focus.

jarmo commented 13 years ago

I'm not sure if it's possible. If anyone knows then please chime in.

snscaimito commented 13 years ago

There is a way to check whether an element has the focus. With sending keystrokes to the parent window we should be able to tab from one element to the next. I don't think that we can find out the tab order itself but we should be fine with the ability to tab from one thing to the next. I'm working on that at the moment.

jarmo commented 13 years ago

I guess that sending tab keystrokes is already working with #send_keys, no?

There's a function called GetFocus which returns the hwnd to something which has focus. I'm not sure if it returns hwnd of the button if it has focus (since it is a child window technically) or if it returns only the hwnd of that window where that button resides. The problem here is that there's no foolproof way of making sure what is behind that handle - is it a button, is it a text field or is it something else?

But if GetFocus returns the handle to the control instead of the main window then there would be possible to add boolean method #focus? or something similar to all controls which would just do something like this: def focus? hwnd == GetFocus() end

snscaimito commented 13 years ago

Re: #send_keys... Yes and no. I introduced a new method #send_keystrokes that allow you to do something like this send_keystrokes("{tab}{tab}abc"). Sends two TAB keystrokes and then enters the letters abc into whatever control is now in focus. This is the first draft and I want to extend this for other special keys like {alt}. After that is done we can then drop #send_keystrokes and move the functionality to #send_keys.

Thanks for the hint at GetFocus(). I will look into that now.

jarmo commented 12 years ago

This seems to be implemented at least in Win32 adapter. Closing.