diff --git a/.circleci/config.yml b/.circleci/config.yml index ed05ed4..41ed879 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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: @@ -83,4 +84,5 @@ jobs: workflows: main: jobs: - - build-and-test + - build-and-test-windows + diff --git a/.idea/workspace.xml b/.idea/workspace.xml index fee017f..a840fa3 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,12 +1,7 @@ - - - - - - + + @@ -74,8 +70,8 @@ - - + + - + - + - + - + @@ -304,7 +300,9 @@ - + + + @@ -346,15 +344,16 @@ + - + - + @@ -383,6 +382,7 @@ + @@ -393,6 +393,7 @@ + diff --git a/circle_ci_test/unit_test/keyboard/keyboard_write_test.py b/circle_ci_test/unit_test/keyboard/keyboard_write_test.py index 62a23ef..ea436f1 100644 --- a/circle_ci_test/unit_test/keyboard/keyboard_write_test.py +++ b/circle_ci_test/unit_test/keyboard/keyboard_write_test.py @@ -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) + diff --git a/je_auto_control/linux_with_x11/keyboard/x11_linux_keyboard_control.py b/je_auto_control/linux_with_x11/keyboard/x11_linux_keyboard_control.py index b7c0838..0dcc715 100644 --- a/je_auto_control/linux_with_x11/keyboard/x11_linux_keyboard_control.py +++ b/je_auto_control/linux_with_x11/keyboard/x11_linux_keyboard_control.py @@ -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 @@ -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() @@ -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() diff --git a/je_auto_control/linux_with_x11/mouse/x11_linux_mouse_control.py b/je_auto_control/linux_with_x11/mouse/x11_linux_mouse_control.py index 799453f..b3cab32 100644 --- a/je_auto_control/linux_with_x11/mouse/x11_linux_mouse_control.py +++ b/je_auto_control/linux_with_x11/mouse/x11_linux_mouse_control.py @@ -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 @@ -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() @@ -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() @@ -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() diff --git a/je_auto_control/wrapper/auto_control_keyboard.py b/je_auto_control/wrapper/auto_control_keyboard.py index b0009df..e3f3b9e 100644 --- a/je_auto_control/wrapper/auto_control_keyboard.py +++ b/je_auto_control/wrapper/auto_control_keyboard.py @@ -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) diff --git a/setup.py b/setup.py index 0b45514..319ef5a 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="je_auto_control", - version="0.0.75", + version="0.0.76", author="JE-Chen", author_email="zenmailman@gmail.com", description="auto testing", diff --git a/test/unit_test/platform_independent/test/critical_exit/critical_exit_test.py b/test/unit_test/platform_independent/test/critical_exit/critical_exit_test.py index 75a83ca..093b3b3 100644 --- a/test/unit_test/platform_independent/test/critical_exit/critical_exit_test.py +++ b/test/unit_test/platform_independent/test/critical_exit/critical_exit_test.py @@ -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: diff --git a/test/unit_test/platform_independent/test/execute_action/execute_action_test.py b/test/unit_test/platform_independent/test/execute_action/execute_action_test.py index 0986805..c75c30a 100644 --- a/test/unit_test/platform_independent/test/execute_action/execute_action_test.py +++ b/test/unit_test/platform_independent/test/execute_action/execute_action_test.py @@ -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) diff --git a/test/unit_test/platform_independent/test/image/locate_all_image.py b/test/unit_test/platform_independent/test/image/locate_all_image.py index 820f7aa..bbd684b 100644 --- a/test/unit_test/platform_independent/test/image/locate_all_image.py +++ b/test/unit_test/platform_independent/test/image/locate_all_image.py @@ -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) diff --git a/test/unit_test/platform_independent/test/image/locate_and_click.py b/test/unit_test/platform_independent/test/image/locate_and_click.py index 4c311bb..0e6f266 100644 --- a/test/unit_test/platform_independent/test/image/locate_and_click.py +++ b/test/unit_test/platform_independent/test/image/locate_and_click.py @@ -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) diff --git a/test/unit_test/platform_independent/test/image/locate_image_center.py b/test/unit_test/platform_independent/test/image/locate_image_center.py index feee845..0b466fd 100644 --- a/test/unit_test/platform_independent/test/image/locate_image_center.py +++ b/test/unit_test/platform_independent/test/image/locate_image_center.py @@ -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) diff --git a/test/unit_test/platform_independent/test/keyboard/keyboard_is_press_test.py b/test/unit_test/platform_independent/test/keyboard/keyboard_is_press_test.py index 48bdd5a..6f414ab 100644 --- a/test/unit_test/platform_independent/test/keyboard/keyboard_is_press_test.py +++ b/test/unit_test/platform_independent/test/keyboard/keyboard_is_press_test.py @@ -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 @@ -39,4 +39,4 @@ elif sys.platform in ["darwin"]: release_key("f5") elif sys.platform in ["linux", "linux2"]: - release_key("backspace") + release_key("a") diff --git a/test/unit_test/platform_independent/test/keyboard/keyboard_write_test.py b/test/unit_test/platform_independent/test/keyboard/keyboard_write_test.py index ad16914..ea436f1 100644 --- a/test/unit_test/platform_independent/test/keyboard/keyboard_write_test.py +++ b/test/unit_test/platform_independent/test/keyboard/keyboard_write_test.py @@ -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") @@ -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) +