dmark1021 / sikuli-api

Automatically exported from code.google.com/p/sikuli-api
0 stars 0 forks source link

How to handle 'hover' in Sikuli Java API #23

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
My question is: How to handle 'hover' in Sikuli Java API (not Sikuli Script)

I am actually trying to hover on a web element (clicking doesn't do the job). 
In the Sikuli script there used to be a function called 'hover' which did the 
job, but now after I have switched to Sikuli Java API, I am having difficulty.

Please help!

Thank you.

Original issue reported on code.google.com by lasyaku...@gmail.com on 23 Jan 2013 at 10:51

GoogleCodeExporter commented 9 years ago
Currently there is no such method in the API.
I use this workaround:

public static ScreenRegion hover(ScreenRegion region) {
  final Mouse mouse = new DesktopMouse();
  mouse.drop(region.getCenter());
  return region;
}

Original comment by miglecz on 24 Jan 2013 at 11:41

GoogleCodeExporter commented 9 years ago
Thanks for the reply, but what did you use as the parameter 'region' here? I 
tried using it by passing the image path as a parameter, but it doesn't work 
for me. 

Actually, my requirement is, I need to hover over a Button and then it shows 
the Sub-menu.

Original comment by lasyaku...@gmail.com on 24 Jan 2013 at 9:34

GoogleCodeExporter commented 9 years ago
Basic usage:
http://code.google.com/p/sikuli-api/wiki/BasicUsage

More examples:
http://code.google.com/p/sikuli-api/w/list

Original comment by miglecz on 24 Jan 2013 at 9:44

GoogleCodeExporter commented 9 years ago
Oh no, I did try to tell you that I don't know what a region is, but what I 
meant was, when I used mouse.drop(), it didn't work for me. And I was trying to 
ask you if you have any troubleshooting tips for the same. Thanks.

Original comment by lasyaku...@gmail.com on 24 Jan 2013 at 10:05

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Okay, I figured it out now. This is the method I created to use for a hover on 
an image, which is defined by the region 'r':

ScreenRegion s = new DesktopScreenRegion();
ScreenRegion r;

public ScreenRegion hover(String image, ScreenRegion r) {       

        Target target = new ImageTarget(new File(image));
    r = s.wait(target, 5000);
    s.find(target);

        final Mouse mouse = new DesktopMouse();
        mouse.drop(r.getCenter());
        return r;
    }

Thanks for the help.

Original comment by lasyaku...@gmail.com on 29 Jan 2013 at 10:04

GoogleCodeExporter commented 9 years ago

Original comment by doubles...@gmail.com on 26 Feb 2013 at 7:37