Script:
=====
import os, sys, time
sys.path.append(os.path.dirname(os.path.realpath(__file__)) + '/sikulixapi.jar')
from org.sikuli.script import App
from org.sikuli.script import Screen
from org.sikuli.basics import Settings
from org.sikuli.script import Mouse
from org.sikuli.script import Location
class Sikuli:
def __init__(self): Mouse.setMouseMovedAction(0) # 0 - Disable User Mouse Interaction Settings.MoveMouseDelay = 0.1 # Doesn't work if Settings.setShowActions(False) is executed afterwards
# Settings.Highlight = False # True - Fires two Times per Action
# Settings.setShowActions(False) # False - does disable the Settings.MoveMouseDelay Setting
# Mouse.setMouseMovedHighlight(True) # Doesn't show any Effect Settings.MinSimilarity = 0.95 Settings.DebugLogs = False
self.screen = Screen() self.highlight = True self.mouse_move_away_method = 'Offset' # Origin, Offset
def move(self, x, y):
loc = Location(x, y) Mouse.move(loc)
def click_image(self, image, timeout=5):
if self.mouse_move_away_method == 'Origin': self.move(0, 0)
if self.mouse_move_away_method == 'Offset': self.move_offset(-50, -50)
reg = self.screen.wait(image, timeout)
if self.highlight: reg.highlight(0.9) # Float Values lower than 1.0 not possible; reg.highlight() disable the Click Action; Clicks doesn't come trough; Use reg.highlight(<int>) instead self.screen.click(image)
Versions:
========
Jython 2.7.0
SikuliXApi.jar Version 1.1.4
Windows 10
Question:
========
The reg.highlight(0.9) throw an Exception:
PS E:\Audio\Audio Installer\Jython\Test> jython .\Script.py
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.python.core.PySystemState (file:/C:/jython2.7.0/jython.jar) to method java.io.Console.encoding()
WARNING: Please consider reporting this to the maintainers of org.python.core.PySystemState
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[log] highlight M[1027,680 74x22]On(0) S 10000 for 0.9 secs
Traceback (most recent call last):
File ".\Ableton.py", line 11, in <module>
sik.click_image(r'..\..\Images\test_next.png')
File "..\sikulix.py", line 52, in click_image
reg.highlight(0.9) # Float Values like 0.1 not possible; reg.highlight() disable the Click Action; Clicks doesn't come trough; Use reg.highlight(<int>) instead
at java.base/java.lang.Thread.sleep(Native Method)
at org.sikuli.util.ScreenHighlighter.closeAfter(ScreenHighlighter.java:144)
at org.sikuli.util.ScreenHighlighter.highlight(ScreenHighlighter.java:214)
at org.sikuli.script.Region.highlight(Region.java:2164)
at org.sikuli.script.Region.highlight(Region.java:2142)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: timeout value is negative
Script: append( os.path. dirname( os.path. realpath( __file_ _)) + '/sikulixapi.jar')
=====
import os, sys, time
sys.path.
from org.sikuli.script import App
from org.sikuli.script import Screen
from org.sikuli.basics import Settings
from org.sikuli.script import Mouse
from org.sikuli.script import Location
class Sikuli:
def __init__(self):
Mouse. setMouseMovedAc tion(0) # 0 - Disable User Mouse Interaction
Settings. MoveMouseDelay = 0.1 # Doesn't work if Settings. setShowActions( False) is executed afterwards setShowActions( False) # False - does disable the Settings. MoveMouseDelay Setting ovedHighlight( True) # Doesn't show any Effect
Settings. MinSimilarity = 0.95
Settings. DebugLogs = False
self.highlight = True
self.mouse_ move_away_ method = 'Offset' # Origin, Offset
# Settings.Highlight = False # True - Fires two Times per Action
# Settings.
# Mouse.setMouseM
self.screen = Screen()
def app(self, app):
self. app = App(app)
self. app = App(app)
try:
except:
pass
finally:
def app_open(self):
self.app. open()
def app_close(self):
self.app. close()
def move_offset(self, x, y):
Mouse. move(x, y)
def move(self, x, y):
Mouse. move(loc)
loc = Location(x, y)
def click_image(self, image, timeout=5): move_away_ method == 'Origin':
self. move(0, 0) move_away_ method == 'Offset':
self. move_offset( -50, -50) wait(image, timeout)
reg. highlight( 0.9) # Float Values lower than 1.0 not possible; reg.highlight() disable the Click Action; Clicks doesn't come trough; Use reg.highlight( <int>) instead
self.screen. click(image)
if self.mouse_
if self.mouse_
reg = self.screen.
if self.highlight:
Versions:
========
Jython 2.7.0
SikuliXApi.jar Version 1.1.4
Windows 10
Question:
========
The reg.highlight(0.9) throw an Exception:
PS E:\Audio\Audio Installer\ Jython\ Test> jython .\Script.py core.PySystemSt ate (file:/ C:/jython2. 7.0/jython. jar) to method java.io. Console. encoding( ) core.PySystemSt ate access= warn to enable warnings of further illegal reflective access operations click_image( r'..\.. \Images\ test_next. png') highlight( 0.9) # Float Values like 0.1 not possible; reg.highlight() disable the Click Action; Clicks doesn't come trough; Use reg.highlight( <int>) instead java.lang. Thread. sleep(Native Method) util.ScreenHigh lighter. closeAfter( ScreenHighlight er.java: 144) util.ScreenHigh lighter. highlight( ScreenHighlight er.java: 214) script. Region. highlight( Region. java:2164) script. Region. highlight( Region. java:2142) jdk.internal. reflect. NativeMethodAcc essorImpl. invoke0( Native Method) jdk.internal. reflect. NativeMethodAcc essorImpl. invoke( NativeMethodAcc essorImpl. java:62) jdk.internal. reflect. DelegatingMetho dAccessorImpl. invoke( DelegatingMetho dAccessorImpl. java:43) java.lang. reflect. Method. invoke( Method. java:566)
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.python.
WARNING: Please consider reporting this to the maintainers of org.python.
WARNING: Use --illegal-
WARNING: All illegal access operations will be denied in a future release
[log] highlight M[1027,680 74x22]On(0) S 10000 for 0.9 secs
Traceback (most recent call last):
File ".\Ableton.py", line 11, in <module>
sik.
File "..\sikulix.py", line 52, in click_image
reg.
at java.base/
at org.sikuli.
at org.sikuli.
at org.sikuli.
at org.sikuli.
at java.base/
at java.base/
at java.base/
at java.base/
java.lang. IllegalArgument Exception: java.lang. IllegalArgument Exception: timeout value is negative