-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
hold down the keys!!! #86
Comments
Please do not create new issue each time, but continue the discussion under the old one. I don't understand why this code does not work for you then: window.send_keys [:control, :shift, :f7] That's exactly what it is supposed to do - holding down control, shift and pressing f7 at the same time. Do you want something different to happen? You can try |
@jarmo - Can we use function press_key, to hold keys? |
No, because it is private method and not intended for public use. You don't need it either. Can you explain, why the suggested |
@jarmo - In my case i want to press f7 multiple times while holding down control+shift. |
@jarmo - To be precise in my application when i hold down a (ctrl+shift) a panel appears and to navigate through that panel i need to press f7 multiple times while holding down the keys ctrl+shift. |
In that case, try like this: window.send_keys [:control, :shift, :f7, :f7, :f7] Or 3.times { window.send_keys [:control, :shift, :f7] } |
send_keys function uses press_key and release_key at the same time, but here @Pareshwardhan needs to use the functionality of press_key on [:control] + [:shift] and send_key on [:f7] and after selecting a particular item from panel, release_key[:control] and [:shift] |
Ok, can you tell me step by step how would you do it manually with your hands using real keyboard. Currently i'm not sure i understand it correctly. Are you saying that control+shift+f7 will open up the panel and you have to select something from there with your mouse and only after that you can release control+shift? |
Yes you are somewhat correct. But f7 key need to be pressed separately, for selecting purpose. control + shift should be pressed and hold first then in order to navigate through options, f7 key will be pressed (not mouse). And after selecting a particular option (while navigating) through f7 key, need to release the control + shift. |
It sounds like the desired use case IS to be able to hold down on a key for an arbitrary amount of time before releasing it (as a separate command so that other stuff can be done in between the two). Is there a reason not to have a public equivalent to #press_key? |
@jarmo -Hye i want to perform multi select functionality, for that i am using shift down + down arrow key but it is not working out, how can i resolve it? |
My provided examples does just that - keeps control+shift pressed while pressing f7. What happens if you try the solutions i provided above? It is quite hard (or rather impossible) to help if you don't give any feedback at all. |
The examples you have provided does not work here. It does not have control on selecting a particular option from the panel. Your example press all these 3 keys [control+shift+f7] parallelly, this is not the requirement. |
How come? You said that you need to press control+shift and keep them pressed while pressing f7 - this means that you press them all at the same time. Do i misunderstand anyhow? |
Yes you misunderstand. We need press_key functionality, as simple as that. |
So you're saying that while holding down control+shift and pressing f7 at the same time, then nothing happens? Or does something happen and this is not the expected behavior? Can you tell me exactly what happens and what do you expect to happen? I don't understand how is it different to hold down control+shift then press f7 and release control+shift rather than hold down control+shift+f7 and then release them. Seems to me like a usability failure in your application when that combination does not work the same as the former. Since RAutomation is written in Ruby then you can execute private methods as well with some hacking. Untested: window.activate
win32_window = window.instance_variable_get :@window
win32_window.send(:press_key, RAutomation::Adapter::Win32::Keys.encode(:control))
win32_window.send(:press_key, RAutomation::Adapter::Win32::Keys.encode(:shift))
window.send_keys :f7, :f7, :f7
win32_window.send(:release_key, RAutomation::Adapter::Win32::Keys.encode(:control))
win32_window.send(:release_key, RAutomation::Adapter::Win32::Keys.encode(:shift)) This is not part of the public API, because it does not make sense to have a functionality like this and it might cause many problems - some keys might be left pressed and will cause problems. As i said above - this seems to be an usability issue. Also, the API has been "stolen" from webdriver API, which also does not support functionality like this (at least i'm not aware of). |
Granted, the application in question could be a nightmare when it comes to usability. But is that a good reason to not be able to automate it? If accomplishing some goal in an application requires the user to hold down ctrl+shift, click on a nav link with the mouse, press the page down key a few times to bring an item into view, press F7 to pick that item, and then finally release ctrl+shift...then, yes, that application has a poor user experience. But automation is about relieving a human of the burden of doing some task. The silliness of the task should factor into it only if relieving said burden places one that is just as large on the automation tool. In this case, the burden on the automation tool is just having a public #press_key and #release_key. That's not too much to ask. Having a similar look and feel to the webdriver API is not a bad idea. If there are analogous actions that both APIs perform then it is a nice touch to have them line up so closely. However, that's not reason to limit ourselves to the webdriver API. Just because they -don't- doesn't mean that we -can't-. |
I'm with @jarmo on this. I wouldn't want to expose our privates to expose an API to accommodate the exception rather than the rule. Leaving something in a If he wants to have it, that's what monkey patching is for :-) |
@leviwilson If there is a functionality of #press_key then there is #realease_key to restore the key into initial state. isn't it?? |
Did you try what was suggested up above? |
yes i tried but i got the error message "NoMethodError: undefined method `reduce' for :control:Symbol"!!!!! |
Yeah, So, it's: window.activate
win32_window = window.instance_variable_get :@window
win32_window.send(:press_key, RAutomation::Adapter::Win32::Keys.encode([:control]).first)
win32_window.send(:press_key, RAutomation::Adapter::Win32::Keys.encode([:shift]).first)
window.send_keys :f7, :f7, :f7
win32_window.send(:release_key, RAutomation::Adapter::Win32::Keys.encode([:control]).first)
win32_window.send(:release_key, RAutomation::Adapter::Win32::Keys.encode([:shift]).first) Next time please provide us with your code and backtrace. It would be much more helpful :) |
Thanks @jarmo and @leviwilson, now its working. :) |
Thank u!!!! :) |
Hi Jarmo,
In the issue #85 i meant that i want to hold down a key .For example to select multiple folders we need to hold down the control key and click on the folders we want to select.
In my case i need to press F7 key after holding down (ctrl+shift). I hope My issue is clear to u.
The text was updated successfully, but these errors were encountered: