how do i swipe right or left on an android emulator using Sikuli IDE

Asked by Vinay

how do i swipe right or left on an android emulator using Sikuli IDE? i can able to scroll up and down but not for right and left from one screen to another screen(for bharat matrimony) app.

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Roman Podolyan (podolyan-roman) said :
#1

You can write your own custom mouse swipe function using low-level mouse control routines.

To illustrate the idea, here is dirty routine I used for that:

def flick_up():
        # setting begin - end
        x1, y1, x2, y2 = (640, 682, 640, 412)
        start = Location(x1, y1)
        end = Location(x2, y2)
        # moving up
        stepX = 0
        stepY = 20
        run = start
        mouseMove(start); wait(0.5)
        mouseDown(Button.LEFT); wait(0.5)
        for i in range(5):
                        run = run.right(stepX).above(stepY * i)
                        mouseMove(run)
                        wait(0.05)
        mouseUp()
        wait(0.5)

Experiment a bit with mouseMove, and you'll get whatever is possible.

Revision history for this message
HAL-9000 (coldlogic) said :
#2

I use variations of this function all the time to find specific objects in a list.

def ScrollDown(target, anchor, stop):
    while not region.exists(target):
        region.dragDrop(anchor.below(some-number-of-pixels), anchor)
        if region.exists(stop):
            break

target = what you want to find in the list.
anchor = something permanent on the region (you have to find() the target before executing this loop).
stop = something to break the loop if its not finding the target. Usually, this will be some proprietary image at the bottom of the list.

If you want to swipe left etc. you just specify that in the dragDrop in lieu of 'below.'

One thing though I have not figured out personally is how to do a true heuristic 'flick.' This is where, like say on a mobile smartphone, you 'flick' the screen and it keeps scrolling several seconds after you stopped touching the screen.

The touch layer on Windoze 8 Metro and all the smartphones only pick up that heuristic if the mouse is accelerating through the dragDrop, and I do not know how to do that in Python.

Can you help with this problem?

Provide an answer of your own, or ask Vinay for more information if necessary.

To post a message you must log in.