Skip to content
Merged

Dev #52

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
4 changes: 2 additions & 2 deletions .github/workflows/auto-control-github-actions_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.5
- name: Set up Python 3.7
uses: actions/setup-python@v3
with:
python-version: "3.5"
python-version: "3.7"
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/auto-control-github-actions_stable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Set up Python 3.5
uses: actions/setup-python@v3
with:
python-version: "3.5"
python-version: "3.7"
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel
Expand Down
2 changes: 1 addition & 1 deletion .idea/Python_JEAutoControl.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

88 changes: 47 additions & 41 deletions .idea/workspace.xml

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions autocontrol_driver/generate_autocontrol_driver.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from je_auto_control import start_autocontrol_socket_server

if "__main__" == __name__:
server = start_autocontrol_socket_server()
while not server.close_flag:
pass
2 changes: 1 addition & 1 deletion dev_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="je_auto_control_dev",
version="0.0.33",
version="0.0.36",
author="JE-Chen",
author_email="[email protected]",
description="auto testing",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,32 @@ AutoControlGUI Executor Doc
"""
from je_auto_control import execute_action
from je_auto_control import test_record
example_list = [
"windows"
example_list = [
["type_key", {"keycode": 65}],
["mouse_left", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
["position"],
["press_mouse", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
["release_mouse", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}]
]
"macos"
example_list = [
["type_key", {"keycode": 0x00}],
["mouse_left", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
["position"],
["press_mouse", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
["release_mouse", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
["type_key", {"mouse_keycode": "dwadwawda", "dwadwad": 500, "wdawddwawad": 500}]
]
"linux"
example_list = [
["type_key", {"keycode": 38}],
["mouse_left", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
["position"],
["press_mouse", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
["release_mouse", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
["type_key", {"mouse_keycode": "dwadwawda", "dwadwad": 500, "wdawddwawad": 500}]
]
execute_action(example_list)

def read_action_json(json_file_path: str):
Expand Down
2 changes: 2 additions & 0 deletions je_auto_control/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,5 @@
# file process
from je_auto_control.utils.file_process.get_dir_file_list import get_dir_files_as_list
from je_auto_control.utils.file_process.create_project_structure import create_template_dir
# socket server
from je_auto_control.utils.socket_server.AutoControlSocketServer import start_autocontrol_socket_server
2 changes: 1 addition & 1 deletion je_auto_control/utils/critical_exit/critcal_exit.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(self, default_daemon: bool = True):
"""
super().__init__()
self.setDaemon(default_daemon)
self._exit_check_key = keys_table.get("f7")
self._exit_check_key: int = keys_table.get("f7")

def set_critical_key(self, keycode: [int, str] = None) -> None:
"""
Expand Down
78 changes: 39 additions & 39 deletions je_auto_control/utils/exception/exception_tag.py
Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@
# error tags
je_auto_control_error = "Auto control error"
je_auto_control_critical_exit_error = "Auto control critical exit error"
je_auto_control_error: str = "Auto control error"
je_auto_control_critical_exit_error: str = "Auto control critical exit error"
# os tags
linux_import_error = "should be only loaded on linux"
osx_import_error = "should be only loaded on MacOS"
windows_import_error = "should be only loaded on windows"
macos_record_error = "macos cant use recorder"
linux_import_error: str = "should be only loaded on linux"
osx_import_error: str = "should be only loaded on MacOS"
windows_import_error: str = "should be only loaded on windows"
macos_record_error: str = "macos cant use recorder"
# keyboard tags
keyboard_error = "Auto control keyboard error"
keyboard_press_key = "keyboard press key error"
keyboard_release_key = "keyboard release key error"
keyboard_type_key = "keyboard type key error"
keyboard_write = "keyboard write error"
keyboard_write_cant_find = "keyboard write error cant find key"
keyboard_hotkey = "keyboard hotkey error"
keyboard_error: str = "Auto control keyboard error"
keyboard_press_key: str = "keyboard press key error"
keyboard_release_key: str = "keyboard release key error"
keyboard_type_key: str = "keyboard type key error"
keyboard_write: str = "keyboard write error"
keyboard_write_cant_find: str = "keyboard write error cant find key"
keyboard_hotkey: str = "keyboard hotkey error"
# mouse tags
mouse_error = "Auto control mouse error"
mouse_get_position = "mouse get position error"
mouse_set_position = "mouse set position error"
mouse_press_mouse = "mouse press mouse error"
mouse_release_mouse = "mouse release key error"
mouse_click_mouse = "mouse click mouse error"
mouse_scroll = "mouse scroll error"
mouse_wrong_value = "mouse value error"
mouse_error: str = "Auto control mouse error"
mouse_get_position: str = "mouse get position error"
mouse_set_position: str = "mouse set position error"
mouse_press_mouse: str = "mouse press mouse error"
mouse_release_mouse: str = "mouse release key error"
mouse_click_mouse: str = "mouse click mouse error"
mouse_scroll: str = "mouse scroll error"
mouse_wrong_value: str = "mouse value error"
# screen tags
screen_error = "Auto control screen error"
screen_get_size = "screen get size error"
screen_screenshot = "screen screenshot error"
screen_error: str = "Auto control screen error"
screen_get_size: str = "screen get size error"
screen_screenshot: str = "screen screenshot error"
# table tags
table_cant_find_key = "cant find key error"
table_cant_find_key: str = "cant find key error"
# image tags
cant_find_image = "cant find image"
find_image_error_variable = "variable error"
cant_find_image: str = "cant find image"
find_image_error_variable: str = "variable error"
# listener tags
listener_error = "Auto control listener error"
listener_error: str = "Auto control listener error"
# test_record tags
record_queue_error = "cant get test_record queue its none are you using stop test_record before test_record"
record_not_found_action_error = "test_record action not found"
record_queue_error: str = "cant get test_record queue its none are you using stop test_record before test_record"
record_not_found_action_error: str = "test_record action not found"
# json action file tag
cant_execute_action_error = "cant execute action"
cant_find_json_error = "cant find json file"
cant_save_json_error = "cant save json file"
action_is_null_error = "json action is null"
cant_execute_action_error: str = "cant execute action"
cant_find_json_error: str = "cant find json file"
cant_save_json_error: str = "cant save json file"
action_is_null_error: str = "json action is null"
# timeout tag
timeout_need_on_main_error = "should put timeout function on main"
timeout_need_on_main_error: str = "should put timeout function on main"
# HTML
html_generate_no_data_tag = "record is None"
html_generate_no_data_tag: str = "record is None"
# add command
add_command_exception_tag = "command value type should be as method or function"
add_command_exception_tag: str = "command value type should be as method or function"
# executor
executor_list_error = "executor receive wrong data list is none or wrong type"
executor_list_error: str = "executor receive wrong data list is none or wrong type"
# argparse
argparse_get_wrong_data = "argparse receive wrong data"
argparse_get_wrong_data: str = "argparse receive wrong data"
6 changes: 3 additions & 3 deletions je_auto_control/utils/executor/action_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
class Executor(object):

def __init__(self):
self.event_dict = {
self.event_dict: dict = {
# mouse
"mouse_left": click_mouse,
"mouse_right": click_mouse,
Expand Down Expand Up @@ -69,7 +69,7 @@ def execute_action(self, action_list: [list, dict]) -> dict:
for loop the list and execute action
"""
if type(action_list) is dict:
action_list = action_list.get("auto_control", None)
action_list: list = action_list.get("auto_control", None)
if action_list is None:
raise AutoControlActionNullException(executor_list_error)
execute_record_dict = dict()
Expand Down Expand Up @@ -100,7 +100,7 @@ def execute_files(self, execute_files_list: list) -> list:
:param execute_files_list: list include execute files path
:return: every execute detail as list
"""
execute_detail_list = list()
execute_detail_list: list = list()
for file in execute_files_list:
execute_detail_list.append(self.execute_action(read_action_json(file)))
return execute_detail_list
Expand Down
2 changes: 1 addition & 1 deletion je_auto_control/utils/html_report/html_report_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def generate_html(html_name: str = "default_name") -> str:
if len(test_record_instance.test_record_list) == 0:
raise AutoControlHTMLException(html_generate_no_data_tag)
else:
event_str = ""
event_str: str = ""
for record_data in test_record_instance.test_record_list:
# because data on record_data all is str
if record_data.get("program_exception") == "None":
Expand Down
38 changes: 38 additions & 0 deletions je_auto_control/utils/socket_server/AutoControlSocketServer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import json
import socketserver
import threading

from je_auto_control import execute_action


class TCPServerHandler(socketserver.BaseRequestHandler):

def handle(self):
command_string = str(self.request.recv(8192).strip(), encoding="utf-8")
print("command is: " + command_string)
if command_string == "quit_server":
self.server.shutdown()
self.server.close_flag = True
print("Now quit server")
else:
try:
execute_str = json.loads(command_string)
execute_action(execute_str)
except Exception as error:
print(repr(error))


class TCPServer(socketserver.ThreadingMixIn, socketserver.TCPServer):

def __init__(self, server_address, RequestHandlerClass):
super().__init__(server_address, RequestHandlerClass)
self.close_flag: bool = False


def start_autocontrol_socket_server(host: str = "localhost", port: int = 9938):
server = TCPServer((host, port), TCPServerHandler)
server_thread = threading.Thread(target=server.serve_forever)
server_thread.daemon = True
server_thread.start()
return server

Empty file.
4 changes: 2 additions & 2 deletions je_auto_control/utils/test_record/record_test_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
class TestRecord(object):

def __init__(self, init_record: bool = False):
self.init_record = init_record
self.test_record_list = list()
self.init_record: bool = init_record
self.test_record_list: list = list()

def clean_record(self) -> None:
self.test_record_list = list()
Expand Down
2 changes: 1 addition & 1 deletion je_auto_control/utils/timeout/multiprocess_timeout.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

def multiprocess_timeout(check_function, time: int):
try:
new_process = Process(target=check_function)
new_process: Process = Process(target=check_function)
new_process.start()
new_process.join(timeout=time)
except AutoControlTimeoutException:
Expand Down
50 changes: 25 additions & 25 deletions je_auto_control/windows/core/utils/win32_ctype_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,26 @@

wintypes.ULONG_PTR = wintypes.WPARAM

Mouse = 0
Keyboard = 1
Hardware = 2
Mouse: int = 0
Keyboard: int = 1
Hardware: int = 2


class MouseInput(ctypes.Structure):
_fields_ = (("dx", wintypes.LONG),
("dy", wintypes.LONG),
("mouseData", wintypes.DWORD),
("dwFlags", wintypes.DWORD),
("time", wintypes.DWORD),
("dwExtraInfo", ctypes.c_void_p))
_fields_: tuple = (("dx", wintypes.LONG),
("dy", wintypes.LONG),
("mouseData", wintypes.DWORD),
("dwFlags", wintypes.DWORD),
("time", wintypes.DWORD),
("dwExtraInfo", ctypes.c_void_p))


class KeyboardInput(ctypes.Structure):
_fields_ = (("wVk", wintypes.WORD),
("wScan", wintypes.WORD),
("dwFlags", wintypes.DWORD),
("time", wintypes.DWORD),
("dwExtraInfo", ctypes.c_void_p))
_fields_: tuple = (("wVk", wintypes.WORD),
("wScan", wintypes.WORD),
("dwFlags", wintypes.DWORD),
("time", wintypes.DWORD),
("dwExtraInfo", ctypes.c_void_p))

def __init__(self, *args, **kwds):
super(KeyboardInput, self).__init__(*args, **kwds)
Expand All @@ -43,20 +43,20 @@ def __init__(self, *args, **kwds):


class HardwareInput(ctypes.Structure):
_fields_ = (("uMsg", wintypes.DWORD),
("wParamL", wintypes.WORD),
("wParamH", wintypes.WORD))
_fields_: tuple = (("uMsg", wintypes.DWORD),
("wParamL", wintypes.WORD),
("wParamH", wintypes.WORD))


class Input(ctypes.Structure):
class INPUT_Union(ctypes.Union):
_fields_ = (("ki", KeyboardInput),
("mi", MouseInput),
("hi", HardwareInput))
_fields_: tuple = (("ki", KeyboardInput),
("mi", MouseInput),
("hi", HardwareInput))

_anonymous_ = ("_input",)
_fields_ = (("type", wintypes.DWORD),
("_input", INPUT_Union))
_anonymous_: tuple = ("_input",)
_fields_: tuple = (("type", wintypes.DWORD),
("_input", INPUT_Union))


def _check_count(result, func, args) -> list:
Expand All @@ -65,9 +65,9 @@ def _check_count(result, func, args) -> list:
return args


LPINPUT = ctypes.POINTER(Input)
LPINPUT: ctypes.POINTER = ctypes.POINTER(Input)

SendInput = user32.SendInput
SendInput: user32.SendInput = user32.SendInput

user32.SendInput.errcheck = _check_count
user32.SendInput.arg_types = (wintypes.UINT, ctypes.c_void_p, ctypes.c_int)
2 changes: 1 addition & 1 deletion je_auto_control/windows/core/utils/win32_keypress_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

def check_key_is_press(keycode: [int, str]) -> bool:
if type(keycode) is int:
temp = ctypes.windll.user32.GetKeyState(keycode)
temp: int = ctypes.windll.user32.GetKeyState(keycode)
else:
temp = ctypes.windll.user32.GetKeyState(ord(keycode))
if temp > 1:
Expand Down
Loading