click modifiers don't work (OS X 10.6)

Bug #519916 reported by RaiMan
30
This bug affects 5 people
Affects Status Importance Assigned to Milestone
SikuliX
Fix Released
Critical
Tsung-Hsiang Chang

Bug Description

Sik 098, OS X 10.6.2 (64)

click(<image>, KEY_CTRL) # image found on the desktop
# doesn't work and produces error-sound. image seems to be clicked (mouse pointer there and image selected)

switchApp("Safari")
click(<image>, KEY_CMD) # should open a new tab and go to the linked page
# clicks without modifier (page is opened in current tab as with left click)

Revision history for this message
Mueller (jamuell22) wrote :

Or Window XP, I am having the same troubles with my click modifiers.

Revision history for this message
nitwit (nithardt) wrote :
Revision history for this message
Tsviatko Yovtchev (tsv-yov) wrote :

I get an exception of the kind:

  File "C:\Program Files (x86)\Sikuli\sikuli-ide-full.jar\Lib/python/edu/mit/csail/uid/Sikuli.py", line 438, in click
 at sun.awt.windows.WRobotPeer.keyPress(Native Method)

 at java.awt.Robot.keyPress(Unknown Source)

 at edu.mit.csail.uid.SikuliScript._click(SikuliScript.java:793)

 at edu.mit.csail.uid.SikuliScript._click(SikuliScript.java:763)

 at edu.mit.csail.uid.SikuliScript.click(SikuliScript.java:225)

 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

 at java.lang.reflect.Method.invoke(Unknown Source)

java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: Invalid key code

When I try using click(<Image> , KEY_CTRL).

Revision history for this message
RaiMan (raimund-hocke) wrote :

Whats up with this. Think this should get some priority!

Changed in sikuli:
importance: Undecided → Critical
assignee: nobody → Tsung-Hsiang Chang (vgod)
Changed in sikuli:
status: New → Fix Committed
Revision history for this message
RaiMan (raimund-hocke) wrote :

You did it with 0.9.9. Congratulations. Successfully tested with Windows 7 and Mac OS X 10.6.2.

Changed in sikuli:
status: Fix Committed → Fix Released
Revision history for this message
TPasadena (chou-terrence) wrote :

I found this fix creates another problem.
Before, we call click(img) or wait(img), if the img not found, it will return None or []
After this fix, it will generate exception.

In order to avoid this exception, I call my own _click(img) and _wait(img) in stead of original ones.

Sample code:
def _wait(img, timeout=3000):
   try:
      s = wait(img, timeout)
   except:
      s = []
   return s

Revision history for this message
RaiMan (raimund-hocke) wrote :

well, wait() is a case to think about.

In general I think that its ok to have the FindFailed exceptions, because normally a workflow should stop when something is not found. It makes no sense to go on, since something is different from what you expected.

So i use:

import sys
try:
 .... click() and all the stuff
 .... the workflow
except FindFailed: # possible with 0.9.9
 popup(str(sys.exc_info()[1])) # info: line number and picture filename
except Exception:
 ... all the others

with setThrowException(True/False) you can always switch between the two behaviors.

I think there should be a 3rd parameter for the wait() to tell it, to either throw exception or return None.

Revision history for this message
RaiMan (raimund-hocke) wrote :

This question not really is the place for ideas on the wait() concerning exception handling.

But since I think that, if an api produces the need to define own overwrites for kernel functions, I will report a bug to motivate some evaluation together with the renewal of the api with version 0.10.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.