Skip to content
Merged

Dev #13

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
version: 2.1

orbs:
win: circleci/windows@2.2.0
windows: circleci/windows@2.4.1

jobs:
build-and-test:
build-and-test-windows:
executor:
name: win/default
name: windows/default
size: medium
shell: powershell.exe

steps:
Expand Down Expand Up @@ -83,4 +84,5 @@ jobs:
workflows:
main:
jobs:
- build-and-test
- build-and-test-windows

77 changes: 39 additions & 38 deletions .idea/workspace.xml

Large diffs are not rendered by default.

12 changes: 9 additions & 3 deletions circle_ci_test/unit_test/keyboard/keyboard_write_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,26 @@
from je_auto_control import release_key
from je_auto_control import write

from je_auto_control import AutoControlKeyboardException

print(keys_table.keys())

press_key("shift")
write("123456789")
press_key("return")
release_key("return")
write("abcdefghijklmnopqrstuvwxyz")
assert (write("abcdefghijklmnopqrstuvwxyz") == "abcdefghijklmnopqrstuvwxyz")
release_key("shift")
press_key("return")
release_key("return")
write("abcdefghijklmnopqrstuvwxyz")
assert (write("abcdefghijklmnopqrstuvwxyz") == "abcdefghijklmnopqrstuvwxyz")
press_key("return")
release_key("return")
"""
this write will print one error -> keyboard write error can't find key : Ѓ and write remain string
"""
write("Ѓ123456789")
try:
assert (write("Ѓ123456789") == "123456789")
except AutoControlKeyboardException as error:
print(repr(error), file=sys.stderr)

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys
import time

from je_auto_control.utils.je_auto_control_exception.exceptions import AutoControlException
from je_auto_control.utils.je_auto_control_exception.exception_tag import linux_import_error
Expand All @@ -15,6 +16,7 @@ def press_key(keycode: int):
"""
:param keycode which keycode we want to press
"""
time.sleep(0.01)
fake_input(display, X.KeyPress, keycode)
display.sync()

Expand All @@ -23,5 +25,6 @@ def release_key(keycode: int):
"""
:param keycode which keycode we want to release
"""
time.sleep(0.01)
fake_input(display, X.KeyRelease, keycode)
display.sync()
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys
import time

from je_auto_control.utils.je_auto_control_exception.exceptions import AutoControlException
from je_auto_control.utils.je_auto_control_exception.exception_tag import linux_import_error
Expand Down Expand Up @@ -33,6 +34,7 @@ def set_position(x: int, y: int):
:param x we want to set mouse x position
:param y we want to set mouse y position
"""
time.sleep(0.01)
fake_input(display, X.MotionNotify, x=x, y=y)
display.sync()

Expand All @@ -41,6 +43,7 @@ def press_mouse(mouse_keycode: int):
"""
:param mouse_keycode mouse keycode we want to press
"""
time.sleep(0.01)
fake_input(display, X.ButtonPress, mouse_keycode)
display.sync()

Expand All @@ -49,6 +52,7 @@ def release_mouse(mouse_keycode: int):
"""
:param mouse_keycode which mouse keycode we want to release
"""
time.sleep(0.01)
fake_input(display, X.ButtonRelease, mouse_keycode)
display.sync()

Expand Down
1 change: 1 addition & 0 deletions je_auto_control/wrapper/auto_control_keyboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def write(write_string: str, is_shift: bool = False, **kwargs):
raise AutoControlKeyboardException(keyboard_write_cant_find)
except AutoControlKeyboardException:
print(keyboard_write_cant_find, single_string, sep="\t", file=sys.stderr)
raise AutoControlKeyboardException(keyboard_write_cant_find)
return record_write_string
except AutoControlKeyboardException:
raise AutoControlKeyboardException(keyboard_write)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="je_auto_control",
version="0.0.75",
version="0.0.76",
author="JE-Chen",
author_email="[email protected]",
description="auto testing",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@
from je_auto_control import keys_table
from je_auto_control import press_key
from je_auto_control import release_key
"""
Create critical exit listener default exit key is keyboard f7
"""
critical_exit_thread = CriticalExit()
"""
set exit key you can use any key in keys_table
"""
print(keys_table.keys())
critical_exit_thread.set_critical_key("f2")
"""
Start listener
"""
critical_exit_thread.init_critical_exit()

"""
now auto press f2 will stop this program
"""
try:
"""
Create critical exit listener default exit key is keyboard f7
"""
critical_exit_thread = CriticalExit()
"""
set exit key you can use any key in keys_table
"""
print(keys_table.keys())
critical_exit_thread.set_critical_key("f2")
"""
Start listener
"""
critical_exit_thread.init_critical_exit()

"""
now auto press f2 will stop this program
"""
while True:
press_key("f2")
except KeyboardInterrupt:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@
["release_mouse", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
]
print("\n\n")
print(execute_action(test_list))
execute_action(test_list)
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
detect_threshold 0~1 , 1 is absolute equal
draw_image, mark the find target
"""
image_data = locate_all_image("../test_source/test_template.png", detect_threshold=0.9, draw_image=False)
image_data = locate_all_image("../../../test_source/test_template.png", detect_threshold=0.9, draw_image=False)
print(image_data)
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
detect_threshold 0~1 , 1 is absolute equal
draw_image, mark the find target
"""
image_data = locate_and_click("../test_source/test_template.png", mouse_keycode="mouse_left", detect_threshold=0.9,
image_data = locate_and_click("../../../test_source/test_template.png", mouse_keycode="mouse_left", detect_threshold=0.9,
draw_image=False)
print(image_data)
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
detect_threshold 0~1 , 1 is absolute equal
draw_image, mark the find target
"""
image_data = locate_image_center("../test_source/test_template.png", detect_threshold=0.9, draw_image=False)
image_data = locate_image_center("../../../test_source/test_template.png", detect_threshold=0.9, draw_image=False)
print(image_data)
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
if check_key_is_press(0x60):
sys.exit(0)
elif sys.platform in ["linux", "linux2"]:
press_key("backspace")
press_key("a")
"""
linux key backspace
linux key a
"""
if check_key_is_press(22):
if check_key_is_press(0):
sys.exit(0)
except AutoControlException:
raise AutoControlException
Expand All @@ -39,4 +39,4 @@
elif sys.platform in ["darwin"]:
release_key("f5")
elif sys.platform in ["linux", "linux2"]:
release_key("backspace")
release_key("a")
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from je_auto_control import release_key
from je_auto_control import write

from je_auto_control import AutoControlKeyboardException

print(keys_table.keys())

press_key("shift")
Expand All @@ -21,4 +23,8 @@
"""
this write will print one error -> keyboard write error can't find key : Ѓ and write remain string
"""
assert (write("Ѓ123456789") == "123456789")
try:
assert (write("Ѓ123456789") == "123456789")
except AutoControlKeyboardException as error:
print(repr(error), file=sys.stderr)