|
1 | | -from . sxgateway import * |
2 | | - |
3 | | -SX = SXPKG.script.SX |
4 | | -SXRegion = SXPKG.script.Region |
5 | | -SXScreen = SXPKG.script.Screen |
6 | | -SXLocation = SXPKG.script.Location |
7 | | -SXImage = SXPKG.script.Image |
8 | | -SXImagePath = SXPKG.script.ImagePath |
9 | | -SXApp = SXPKG.script.App |
10 | | - |
11 | | -class SXBase(): |
12 | | - |
13 | | - SXClass = SX |
14 | | - |
15 | | - def __init__(self, *args): |
16 | | - self.instance = self.SXClass.getDefaultInstance4py() |
17 | | - if len(args) > 0: |
18 | | - self.instance = self.SXClass.make4py(convertArgs(args)) |
19 | | - |
20 | | - def __str__(self): |
21 | | - return self.instance.toString() |
22 | | - |
23 | | - def __getattr__(self, item): |
24 | | - currentObject = self.instance; |
25 | | - |
26 | | - def temp_method(*args, **kwargs): |
27 | | - mCall = item + "(" |
28 | | - mCallError = "" + mCall |
29 | | - countArgs = len(args) |
30 | | - if countArgs > 0: |
31 | | - mCall += "args[0]" |
32 | | - mCallError += "%s" % (args[0]) |
33 | | - for nArg in range(1, countArgs): |
34 | | - mCall += ", args[%d]" % nArg |
35 | | - mCallError += ", %s" % (args[nArg]) |
36 | | - mCall += ")" |
37 | | - mCallError += ")" |
38 | | - try: |
39 | | - toEval = "currentObject." + mCall |
40 | | - result = eval(toEval, {"currentObject": self.instance, "args": args}) |
41 | | - return result |
42 | | - except: |
43 | | - print("Method missing: %s::%s" % (currentObject, mCallError)) |
44 | | - return currentObject |
45 | | - |
46 | | - return temp_method |
47 | | - |
48 | | -class Region(SXBase): |
49 | | - """ |
50 | | - Wrapper for org.sikuli.script.Region |
51 | | -
|
52 | | - - Region() the region of the primary screen |
53 | | - - Region(x,y,w,h) a region at (x,y) with size (w,h) cropped to the containing screen |
54 | | - - Region(otherRegion) make an object-copy of object otherRegion |
55 | | - """ |
56 | | - |
57 | | - SXClass = SXRegion |
58 | | - |
59 | | - def hover(self, *args): |
60 | | - """ |
61 | | - Move the mouse pointer to the given target (args[0]) |
62 | | -
|
63 | | - if the target is |
64 | | - - not given, it will be lastMatch or center (if no lastMatch) of this Region |
65 | | - - an image-filename, a Pattern or an Image, it will first be searched and the valid Match's center/targetOffset will be the target |
66 | | - - a Match: target will be center/targetOffset of the Match |
67 | | - - a Region: target will be center of the Region |
68 | | - - a Location: will be the target |
69 | | -
|
70 | | - :param args: see above |
71 | | - :return: int: 1 if done without errors, 0 otherwise |
72 | | - """ |
73 | | - if len(args) == 0: |
74 | | - return self.instance.hover() |
75 | | - return self.instance.hover(convertArgs(args)) |
76 | | - |
77 | | - def click(self, *args): |
78 | | - if len(args) == 0: |
79 | | - return self.instance.click() |
80 | | - return self.instance.click(convertArgs(args)) |
81 | | - |
82 | | - def highlight(self, *args): |
83 | | - """ |
84 | | - show a colored frame around the region for a given time or switch on/off |
85 | | - |
86 | | - - **() or (color)** switch on/off with color (default red) |
87 | | -
|
88 | | - - **(number) or (number, color)** show in color (default red) for number seconds (cut to int) |
89 | | - |
90 | | - allowed colors given as string |
91 | | - - a color name out of: black, blue, cyan, gray, green, magenta, orange, pink, red, white, yellow (lowercase and |
92 | | - uppercase can be mixed, internally transformed to all uppercase) |
93 | | - - these colornames exactly written: lightGray, LIGHT_GRAY, darkGray and DARK_GRAY |
94 | | - - a hex value like in HTML: #XXXXXX (max 6 hex digits) |
95 | | - - an RGB specification as: #rrrgggbbb where rrr, ggg, bbb are integer values in range 0 - 255 |
96 | | - padded with leading zeros if needed (hence exactly 9 digits) |
97 | | -
|
98 | | - :param args: a valid combination (see above) or omitted |
99 | | - :return: self |
100 | | - """ |
101 | | - if len(args) == 0: |
102 | | - return self.instance.highlight() |
103 | | - return self.instance.highlight4py(convertArgs(args)) |
| 1 | +from . sxbase import * |
| 2 | +from . sxregion import Region |
104 | 3 |
|
105 | 4 | class Screen(Region): |
106 | 5 |
|
|
0 commit comments