Skip to content

Commit 8cacedb

Browse files
authored
Merge pull request #14 from JE-Chen/dev
dev merge to main
2 parents 0b32b69 + bfb7e60 commit 8cacedb

File tree

115 files changed

+685
-280
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+685
-280
lines changed

.circleci/config.yml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ jobs:
1414
- checkout
1515
# pip require package
1616
- run:
17-
command: pip install --user -r requirements.txt
18-
name: pip requirements.txt
17+
command: pip install --user -r dev_requirements.txt
18+
name: pip dev_requirements.txt
1919
# screen test
2020
- run:
2121
command: python ./circle_ci_test/unit_test/screen/screen_test.py
@@ -47,16 +47,6 @@ jobs:
4747
- run:
4848
command: python ./circle_ci_test/unit_test/exception/test_auto_control_exception.py
4949
name: test_auto_control_exception
50-
# image detect
51-
- run:
52-
command: python ./circle_ci_test/unit_test/image/locate_all_image_test.py
53-
name: locate_all_image_test
54-
- run:
55-
command: python ./circle_ci_test/unit_test/image/locate_and_click_test.py
56-
name: locate_and_click_test
57-
- run:
58-
command: python ./circle_ci_test/unit_test/image/locate_image_center_test.py
59-
name: locate_image_center_test
6050
# critical exit
6151
- run:
6252
command: python ./circle_ci_test/unit_test/critical_exit/critical_exit_test.py
@@ -80,6 +70,17 @@ jobs:
8070
- run:
8171
command: python ./circle_ci_test/unit_test/timeout/timeout_test.py
8272
name: timeout_test
73+
# GUI Test
74+
# image detect
75+
- run:
76+
command: python ./circle_ci_test/gui_test/image/locate_all_image_test.py
77+
name: locate_all_image_test
78+
- run:
79+
command: python ./circle_ci_test/gui_test/image/locate_and_click_test.py
80+
name: locate_and_click_test
81+
- run:
82+
command: python ./circle_ci_test/gui_test/image/locate_image_center_test.py
83+
name: locate_image_center_test
8384

8485
workflows:
8586
main:

.idea/workspace.xml

Lines changed: 63 additions & 50 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
import os
2+
import subprocess
3+
from time import sleep
4+
5+
from je_auto_control import locate_and_click
6+
7+
subprocess.Popen("calc", stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, shell=True)
8+
sleep(3)
9+
locate_and_click(
10+
os.getcwd() + "/circle_ci_test/test_source/1.png",
11+
mouse_keycode="mouse_left",
12+
detect_threshold=0.9,
13+
draw_image=False
14+
)
15+
locate_and_click(
16+
os.getcwd() + "/circle_ci_test/test_source/plus.png",
17+
mouse_keycode="mouse_left",
18+
detect_threshold=0.9,
19+
draw_image=False
20+
)
21+
22+
locate_and_click(
23+
os.getcwd() + "/circle_ci_test/test_source/5.png",
24+
mouse_keycode="mouse_left",
25+
detect_threshold=0.9,
26+
draw_image=False
27+
)
28+
29+
locate_and_click(
30+
os.getcwd() + "/circle_ci_test/test_source/equal.png",
31+
mouse_keycode="mouse_left",
32+
detect_threshold=0.9,
33+
draw_image=False
34+
)
35+
locate_and_click(
36+
os.getcwd() + "/circle_ci_test/test_source/plus.png",
37+
mouse_keycode="mouse_left",
38+
detect_threshold=0.9,
39+
draw_image=False
40+
)
41+
locate_and_click(
42+
os.getcwd() + "/circle_ci_test/test_source/2.png",
43+
mouse_keycode="mouse_left",
44+
detect_threshold=0.9,
45+
draw_image=False
46+
)
47+
locate_and_click(
48+
os.getcwd() + "/circle_ci_test/test_source/plus.png",
49+
mouse_keycode="mouse_left",
50+
detect_threshold=0.9,
51+
draw_image=False
52+
)
53+
locate_and_click(
54+
os.getcwd() + "/circle_ci_test/test_source/3.png",
55+
mouse_keycode="mouse_left",
56+
detect_threshold=0.9,
57+
draw_image=False
58+
)
59+
locate_and_click(
60+
os.getcwd() + "/circle_ci_test/test_source/plus.png",
61+
mouse_keycode="mouse_left",
62+
detect_threshold=0.9,
63+
draw_image=False
64+
)
65+
locate_and_click(
66+
os.getcwd() + "/circle_ci_test/test_source/4.png",
67+
mouse_keycode="mouse_left",
68+
detect_threshold=0.9,
69+
draw_image=False
70+
)
71+
locate_and_click(
72+
os.getcwd() + "/circle_ci_test/test_source/plus.png",
73+
mouse_keycode="mouse_left",
74+
detect_threshold=0.9,
75+
draw_image=False
76+
)
77+
locate_and_click(
78+
os.getcwd() + "/circle_ci_test/test_source/6.png",
79+
mouse_keycode="mouse_left",
80+
detect_threshold=0.9,
81+
draw_image=False
82+
)
83+
locate_and_click(
84+
os.getcwd() + "/circle_ci_test/test_source/plus.png",
85+
mouse_keycode="mouse_left",
86+
detect_threshold=0.9,
87+
draw_image=False
88+
)
89+
locate_and_click(
90+
os.getcwd() + "/circle_ci_test/test_source/7.png",
91+
mouse_keycode="mouse_left",
92+
detect_threshold=0.9,
93+
draw_image=False
94+
)
95+
locate_and_click(
96+
os.getcwd() + "/circle_ci_test/test_source/plus.png",
97+
mouse_keycode="mouse_left",
98+
detect_threshold=0.9,
99+
draw_image=False
100+
)
101+
locate_and_click(
102+
os.getcwd() + "/circle_ci_test/test_source/8.png",
103+
mouse_keycode="mouse_left",
104+
detect_threshold=0.9,
105+
draw_image=False
106+
)
107+
locate_and_click(
108+
os.getcwd() + "/circle_ci_test/test_source/plus.png",
109+
mouse_keycode="mouse_left",
110+
detect_threshold=0.9,
111+
draw_image=False
112+
)
113+
locate_and_click(
114+
os.getcwd() + "/circle_ci_test/test_source/9.png",
115+
mouse_keycode="mouse_left",
116+
detect_threshold=0.9,
117+
draw_image=False
118+
)
119+
locate_and_click(
120+
os.getcwd() + "/circle_ci_test/test_source/equal.png",
121+
mouse_keycode="mouse_left",
122+
detect_threshold=0.9,
123+
draw_image=False
124+
)

circle_ci_test/test_source/1.png

415 Bytes
Loading

circle_ci_test/test_source/2.png

659 Bytes
Loading

circle_ci_test/test_source/3.png

658 Bytes
Loading

circle_ci_test/test_source/4.png

509 Bytes
Loading

circle_ci_test/test_source/5.png

574 Bytes
Loading

circle_ci_test/test_source/6.png

591 Bytes
Loading

circle_ci_test/test_source/7.png

481 Bytes
Loading

circle_ci_test/test_source/8.png

676 Bytes
Loading

circle_ci_test/test_source/9.png

617 Bytes
Loading

circle_ci_test/test_source/equal.png

356 Bytes
Loading

circle_ci_test/test_source/minus.png

305 Bytes
Loading
490 Bytes
Loading

circle_ci_test/test_source/plus.png

411 Bytes
Loading

circle_ci_test/unit_test/exception/test_auto_control_exception.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
from je_auto_control.utils.je_auto_control_exception.exceptions import AutoControlCantFindKeyException
2-
from je_auto_control.utils.je_auto_control_exception.exceptions import AutoControlException
3-
from je_auto_control.utils.je_auto_control_exception.exceptions import AutoControlKeyboardException
4-
from je_auto_control.utils.je_auto_control_exception.exceptions import AutoControlMouseException
5-
from je_auto_control.utils.je_auto_control_exception.exceptions import AutoControlScreenException
6-
from je_auto_control.utils.je_auto_control_exception.exceptions import ImageNotFoundException
1+
from je_auto_control.utils.exception.exceptions import AutoControlCantFindKeyException
2+
from je_auto_control.utils.exception.exceptions import AutoControlException
3+
from je_auto_control.utils.exception.exceptions import AutoControlKeyboardException
4+
from je_auto_control.utils.exception.exceptions import AutoControlMouseException
5+
from je_auto_control.utils.exception.exceptions import AutoControlScreenException
6+
from je_auto_control.utils.exception.exceptions import ImageNotFoundException
77

88
exception_list = [
99
AutoControlException,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
from je_auto_control.utils.je_auto_control_exception.exceptions import ImageNotFoundException
1+
from je_auto_control.utils.exception.exceptions import ImageNotFoundException
22

33
raise ImageNotFoundException("test.png")

circle_ci_test/unit_test/keyboard/hotkey_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from je_auto_control import hotkey
44

55
if sys.platform in ["win32", "cygwin", "msys"]:
6-
hotkey(["lcontrol", "a"])
6+
hotkey_event = hotkey(["lcontrol", "a"])
77
hotkey(["lcontrol", "c"])
88
hotkey(["lcontrol", "v"])
99
hotkey(["lcontrol", "v"])

circle_ci_test/unit_test/keyboard/keyboard_is_press_test.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from je_auto_control import check_key_is_press
44
from je_auto_control import press_key
55
from je_auto_control import release_key
6+
from je_auto_control import AutoControlException
67

78
try:
89
"""
@@ -24,18 +25,18 @@
2425
if check_key_is_press(0x60):
2526
sys.exit(0)
2627
elif sys.platform in ["linux", "linux2"]:
27-
press_key("backspace")
28+
press_key("a")
2829
"""
29-
linux key backspace
30+
linux key a
3031
"""
31-
if check_key_is_press(22):
32+
if check_key_is_press(0):
3233
sys.exit(0)
33-
except Exception:
34-
raise Exception
34+
except AutoControlException:
35+
raise AutoControlException
3536
finally:
3637
if sys.platform in ["win32", "cygwin", "msys"]:
3738
release_key("A")
3839
elif sys.platform in ["darwin"]:
3940
release_key("f5")
4041
elif sys.platform in ["linux", "linux2"]:
41-
release_key("backspace")
42+
release_key("a")
Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,28 @@
1-
import time
1+
import sys
22

3-
from je_auto_control import type_key
43
from je_auto_control import keys_table
4+
from je_auto_control import type_key
5+
from je_auto_control import press_key
6+
from je_auto_control import release_key
7+
from je_auto_control import AutoControlKeyboardException
58

69
"""
710
check keys
811
"""
912
print(keys_table.keys())
10-
"""
11-
Linux in every type and press then release need stop 0.01 time in my computer,i'm not sure it's right?
13+
assert (type_key("T") == "T")
14+
assert (type_key("E") == "E")
15+
assert (type_key("S") == "S")
16+
assert (type_key("T") == "T")
1217

13-
example:
14-
type("T")
15-
time.sleep(0.01)
16-
type("E")
17-
time.sleep(0.01)
18-
type("S")
19-
time.sleep(0.01)
20-
type("T")
21-
time.sleep(0.01)
22-
23-
or:
24-
press_key("T")
25-
release_key("T")
26-
time.sleep(0.01)
27-
"""
18+
try:
19+
type_key("dwadawddwadaw")
20+
except AutoControlKeyboardException as error:
21+
print(repr(error), file=sys.stderr)
22+
# no error system will catch it but may make some system error
23+
# you can try to reconnect usb
24+
type_key(-1)
25+
type_key(18919819819165161616161651651651651231231)
26+
press_key(1616516516516516516515)
27+
release_key(15616516516511)
2828

29-
type_key("T")
30-
type_key("E")
31-
type_key("S")
32-
type_key("T")

circle_ci_test/unit_test/keyboard/keyboard_write_test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,8 @@
2727
assert (write("Ѓ123456789") == "123456789")
2828
except AutoControlKeyboardException as error:
2929
print(repr(error), file=sys.stderr)
30+
try:
31+
write("!#@L@#{@#PL#{!@#L{!#{|##PO}!@#O@!O#P!)KI#O_!K")
32+
except AutoControlKeyboardException as error:
33+
print(repr(error), file=sys.stderr)
3034

circle_ci_test/unit_test/mouse/mouse_test.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import sys
12
import time
23

34
from je_auto_control import position
@@ -6,6 +7,7 @@
67
from je_auto_control import release_mouse
78
from je_auto_control import click_mouse
89
from je_auto_control import mouse_table
10+
from je_auto_control import AutoControlMouseException
911

1012
time.sleep(1)
1113

@@ -19,3 +21,27 @@
1921
press_mouse("mouse_left")
2022
release_mouse("mouse_left")
2123
click_mouse("mouse_left")
24+
try:
25+
set_position(6468684648, 4686468648864684684)
26+
except AutoControlMouseException as error:
27+
print(repr(error), file=sys.stderr)
28+
try:
29+
click_mouse("dawdawddadaawd")
30+
except AutoControlMouseException as error:
31+
print(repr(error), file=sys.stderr)
32+
try:
33+
press_mouse("dawdawdawdawd")
34+
except AutoControlMouseException as error:
35+
print(repr(error), file=sys.stderr)
36+
try:
37+
release_mouse("dwadawdadwdada")
38+
except AutoControlMouseException as error:
39+
print(repr(error), file=sys.stderr)
40+
try:
41+
press_mouse(16515588646)
42+
except AutoControlMouseException as error:
43+
print(repr(error), file=sys.stderr)
44+
try:
45+
release_mouse(1651651915)
46+
except AutoControlMouseException as error:
47+
print(repr(error), file=sys.stderr)

circle_ci_test/unit_test/record/record_test.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,20 @@
33
from je_auto_control import record
44
from je_auto_control import stop_record
55
from je_auto_control import type_key
6+
from je_auto_control import execute_action
67

78
"""
89
this program will type test two time
10+
one time is type key one time is record
911
"""
1012
record()
11-
type_key("t")
12-
type_key("e")
13-
type_key("s")
14-
type_key("t")
15-
sleep(1)
16-
stop_record()
1713
sleep(1)
14+
print(type_key("t"))
15+
print(type_key("e"))
16+
print(type_key("s"))
17+
print(type_key("t"))
18+
sleep(2)
19+
record_result = stop_record()
20+
print(record_result)
21+
execute_action(record_result)
22+
sleep(2)

dev_requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
je_auto_control
1+
je_auto_control_dev
22
pillow
33
wheel
44
twine

0 commit comments

Comments
 (0)