Windows: Clicking doesn't work in some applications

Asked by Piotr Hałaczkiewicz

*** one possible workaround (from comment #9, thanks for contribution)

in some cases it might help, to run your script or the IDE (e.g. using the appropriate .bat files) as admin (from context menu).
This is especially needed if you want to automate the management console.
It too might help for some games, that otherwise would not react on Sikuli clicks.

------------------------------------------------------

In some applications clicking doesn't seem to do anything, although Sikuli finds correct image (mouse pointer is being moved) and says it has been clicked:

capture: java.awt.Rectangle[x=0,y=0,width=1280,height=1024]
1 matches found
[sikuli] click 1 times
[sikuli] click on (432,233) BTN: 16, MOD: 0

It looks like the click from Sikuli is ignored. What can I do to use Sikuli in such applications?

OS: Windows 7 x64
Application in question: MabinogiEU Launcher (it's a launcher/patcher for the Mabinogi Europe MMO).

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
RaiMan Edit question
Last query:
Last reply:
Revision history for this message
srijith (electronicmails1) said :
#1

well, I have seen this in my Application also . Thats why I use doubleClick()

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

if a click does not do anything, the likeliest reason is, that the application window does not have the focus to get clicks and keyboard actions.

try switchApp("text") before the click. text should be a significant part of the window title you are targeting.

already have new version 0.9.9?

Revision history for this message
Piotr Hałaczkiewicz (piotr-halaczkiewicz) said :
#3

I'm using the standalone (.zip) 0.9.9 version (file named Sikuli-IDE-win-20100223).

I tried several things:
- opening the app first, so it gets focused,
- switchingApp first,
- doubleClicking,
- sleeping for several seconds just to make sure everything is ready.

Following script doesn't work:

doubleClick( desktop shortcut ) // app opens as expected
sleep(2)
switchApp("MabinogiEU") // it's focused; becomes highlighted on taskbar (it's the only way to tell, because it doesn't have a title bar)
sleep(2)
doubleClick( "game start" button ) // nothing happens; mouse pointer sometimes moves to the spot, sometimes doesn't

Any clues?

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

I just checked (with google chrome everything works fine):

after
doubleClick( desktop shortcut ) // app opens as expected

the app definitely has the focus, so no additional switchApp needed.

try the following:

btnStart = <capture your start button here>
doubleClick( desktop shortcut ) # to start the app

wait(btnStart, 10000)
# this waits max 10 seconds for your startbutton
# (this is the better way than sleep, to assure, that something
# is really there, before the next statement is executed)

m = find(btnStart)
# to save the match of your button

print m
# you will get some pos and dim info in the message area

click(m)
# the match already found is used as click reference (or doubleClick())

Each statement that uses find() (wait, find, click) will raise an exception FindFailed if not found

make the first test without adjusting the similarity (don't click on the picture and play around with the sliders).
If the button cannot be found, already the wait will fail.

In this case make a second test and adjust the similarity before. The script should end up normally.

If the click does not work, I think there may be 2 reasons left:
--- if test 2 works, but does not click
There is a problem with Pattern objects (by adjusting similarity, a pic is changed to Pattern(image).similar(x)). When they are found, the match region may be displaced against the original position depending on size (a bug), so the click might not hit the point.
--- your app may internally use a different way to capture the mouse activities (sometimes with games), so the way Sikuli clicks may not be compatible.

you can test the click functionality on its own without using find() this way:

make your app ready, so that the start button is visible and do as follows

s = <capture startbutton as region>
# use the top right button "find within a subregion" for this capture
# look, that the center of the capture is exactly where you expect the click to work

m = Match(s.x, s.y, s.w, s.h,1) # this makes a match out of the subregion
click(m)

may be in this case you have to use the switchApp before.

Revision history for this message
Piotr Hałaczkiewicz (piotr-halaczkiewicz) said :
#5

I tried both, here are results:

1st:

# that's the shortcut
capture: java.awt.Rectangle[x=0,y=0,width=1280,height=1024]
1 matches found
[sikuli] click 1 times
[sikuli] click on (1237,113) BTN: 16, MOD: 0

# adjusted similarity to 0.91 because the button is grayed out and unclickable as app starts
capture: java.awt.Rectangle[x=0,y=0,width=1280,height=1024]
0 matches found
capture: java.awt.Rectangle[x=0,y=0,width=1280,height=1024]
0 matches found
capture: java.awt.Rectangle[x=0,y=0,width=1280,height=1024]
1 matches found
capture: java.awt.Rectangle[x=0,y=0,width=1280,height=1024]
1 matches found
Match[818,675-181x53 1,00]@C:\Users\me\AppData\Local\Temp\sikuli1240569755787354755.png
[sikuli] click 1 times
[sikuli] click on (908,701) BTN: 16, MOD: 0

# clicked, but nothing happens

2nd:

# app already running, switchingApp first
[sikuli] SubregionJ: 824,679,168,44 edu.mit.csail.uid.SikuliScript@10c29fe
[sikuli] click 1 times
[sikuli] click on (908,701) BTN: 16, MOD: 0

# still nothing

I also did "Run and show each action" to make sure the (x,y) coordinates are correct and they indeed are.

So, I think it must be related to the app itself. I also make a quick test using Auto Clicker. It couldn't click the "game start" button either.

Is there any solution or workaround in such case?

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

I finally agree, that your app is not clickable the way all these click-helpers around (including Sikuli) are doing this job.

Since I think, that nothing else will happen with this question, you should change it to solved. Anyway it would then expire in a few days.

Revision history for this message
srijith (electronicmails1) said :
#7

yes! i believe that its because the window doesn't have focus. One of the simple solution is using doubleClick()

Revision history for this message
born (born127) said :
#8

It is bad that is not always clear where we need this double click :(

Revision history for this message
Matt Johnes (exposedseo) said :
#9

I had the same problem. Just registered so that I could tell you how I fixed it. You need to run Sikuli as admin. I just click on the bat file and run it as admin. As soon as I did that it started clicking on apps it previously would not click on even when it recognized the target image.

BTC: 19dT7mviXnJusvFX4wznpEPGWhRyxfsp3

Revision history for this message
Miles Midgley (miles-midgley) said :
#10

Thanks Matt. I have been trying everything until I read your post. Worked like a charm. Now I can get on with some coding :)

Can you help with this problem?

Provide an answer of your own, or ask Piotr Hałaczkiewicz for more information if necessary.

To post a message you must log in.