How to select the target region in the screen shot

Asked by santosh

Hi All,
 i got the below java code in google , in this code i have very basic question as how to select the target region in the screen shot.

import org.sikuli.script.*;

public class TestSikuli {

        public static void main(String[] args) {
                Screen s = new Screen();
                try{
                        s.click("imgs/spotlight.png", 0);
                        s.wait("imgs/spotlight-input.png");
                        s.type(null, "hello world\n", 0);
                }
                catch(FindFailed e){
                        e.printStackTrace();
                }

        }

}

please let me know as how to select the target region in the image, i am running on windows and i take the screen shot using print screen button .

Awaiting for the immediate response.

i am new to sikuli please help me out.

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
Parva Thakkar (parva-email) said :
#1

I don't claim I understood question very well and thus answering this question correctly, but in Sikuli, region is set by clicking Create Region button on the top of the IDE apart from creating manually. Refer this -

http://sikuli.org/docx/region.html#creating-a-region-setting-and-getting-attributes

this link has all the information about region in sikuli.

Revision history for this message
santosh (santosh-ssit) said :
#2

Pavan,
let me explain in detail.i am not using Sikuli IDE for capturing the images.
i am directly importing the Sikuli package in eclipse for my Java code .
 in the above code that i got from google i see they have specifed the image
for click method.
Now my doubt since i am not using sikuli IDE how can i specify the target
region.OR whether i need to take the images from Sikuli and then specify the
path in my java code.

so please explain how to do this.

/santosh

On Thu, Oct 20, 2011 at 2:35 AM, Parva Thakkar <
<email address hidden>> wrote:

> Your question #175301 on Sikuli changed:
> https://answers.launchpad.net/sikuli/+question/175301
>
> Status: Open => Answered
>
> Parva Thakkar proposed the following answer:
> I don't claim I understood question very well and thus answering this
> question correctly, but in Sikuli, region is set by clicking Create
> Region button on the top of the IDE apart from creating manually. Refer
> this -
>
> http://sikuli.org/docx/region.html#creating-a-region-setting-and-
> getting-attributes
>
> this link has all the information about region in sikuli.
>
> --
> If this answers your question, please go to the following page to let us
> know that it is solved:
> https://answers.launchpad.net/sikuli/+question/175301/+confirm?answer_id=0
>
> If you still need help, you can reply to this email or go to the
> following page to enter your feedback:
> https://answers.launchpad.net/sikuli/+question/175301
>
> You received this question notification because you asked the question.
>

--

/Santosh

Revision history for this message
santosh (santosh-ssit) said :
#3

Pavan,
let me explain in detail.i am not using Sikuli IDE for capturing the images. i am directly importing the Sikuli package in eclipse for my Java code .
 in the above code that i got from google i see they have specifed the image for click method.
Now my doubt since i am not using sikuli IDE how can i specify the target region.OR whether i need to take the images from Sikuli and then specify the path in my java code.

so please explain how to do this.

/santosh

Revision history for this message
RaiMan (raimund-hocke) said :
#4

@ Santosh

I fully agree with Parva:

look at the docs at http://sikuli.org/docx
to understand, how Sikuli works.

Then make some tests and trials in Sikuli IDE, to get a feeling for what it means to capture a visual object, that is to be used to find or click something on the screen.

Finally you will be able, to transform your examples to Java code, after you have decided for one of the different methods to tell Sikuli where to look for images to be used for finding.

Revision history for this message
sawae (sawae) said :
#5

Santosh
Try this.

import org.sikuli.script.*;
public class TestSikuli {
        public static void main(String[] args) {
                Screen s = new Screen();
                Pattern pImage = new Pattern("imgs/spotlight.png").targetOffset(-10,0);
                Match r = s.exists(pImage,1);
                try{
                        s.click(r, 0);
                        s.wait("imgs/spotlight-input.png");
                        s.type(null, "hello world\n", 0);
                }
                catch(FindFailed e){
                        e.printStackTrace();
                }
        }
}

Can you help with this problem?

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

To post a message you must log in.