Reputation: 21
I have been playing around with monkeyrunner and python/jython and I seem to be finding most of the info I need here so I'm hoping some of the experts can tell me how to make a "device.press" happen multiple times. for the purposes of learning lets say I want to turn the volume all the way down, here is what I've tried so far:
device.press("KEYCODE_VOLUME_DOWN", "DOWN_AND_UP", 8)
and
device.press("KEYCODE_VOLUME_DOWN", "DOWN_AND_UP", 8, 8)
As you may have guessed on my phone and image it takes 8 presses to get volume all the way down, but neither of those lines worked. Is there a way to do it without repeating the line 8 times? I know I could do it that way but it seems a bit messy.
Upvotes: 2
Views: 597
Reputation: 69188
MokeyDevice.press() takes only 2 arguments, the rest are ignored. It could warn you that you are using the wrong number of argument but it silently ignores them.
The correct way is
times = 8
for n in range(times):
device.press("KEYCODE_VOLUME_DOWN", MonkeyDevice.DOWN_AND_UP)
Upvotes: 1