diff --git a/.idea/workspace.xml b/.idea/workspace.xml index eac7758..9bf5e1a 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,7 +1,39 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -47,34 +80,36 @@ \ No newline at end of file diff --git a/dev_setup.py b/dev_setup.py index f55aae6..b7dc7de 100644 --- a/dev_setup.py +++ b/dev_setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="je_auto_control_dev", - version="0.0.44", + version="0.0.48", author="JE-Chen", author_email="zenmailman@gmail.com", description="auto testing", diff --git a/docs/source/doc/auto_control_critical_exit_doc/auto_control_critical_exit_doc.rst b/docs/source/Eng/doc/auto_control_critical_exit_doc/auto_control_critical_exit_doc.rst similarity index 95% rename from docs/source/doc/auto_control_critical_exit_doc/auto_control_critical_exit_doc.rst rename to docs/source/Eng/doc/auto_control_critical_exit_doc/auto_control_critical_exit_doc.rst index 7631588..157d8bc 100644 --- a/docs/source/doc/auto_control_critical_exit_doc/auto_control_critical_exit_doc.rst +++ b/docs/source/Eng/doc/auto_control_critical_exit_doc/auto_control_critical_exit_doc.rst @@ -1,4 +1,4 @@ -AutoControlGUI Critical Exit Doc +AutoControl Critical Exit Doc ========================== .. code-block:: python diff --git a/docs/source/doc/auto_control_executor_doc/auto_control_executor_doc.rst b/docs/source/Eng/doc/auto_control_executor_doc/auto_control_executor_doc.rst similarity index 98% rename from docs/source/doc/auto_control_executor_doc/auto_control_executor_doc.rst rename to docs/source/Eng/doc/auto_control_executor_doc/auto_control_executor_doc.rst index d884aae..b9afdae 100644 --- a/docs/source/doc/auto_control_executor_doc/auto_control_executor_doc.rst +++ b/docs/source/Eng/doc/auto_control_executor_doc/auto_control_executor_doc.rst @@ -1,4 +1,4 @@ -AutoControlGUI Executor Doc +AutoControl Executor Doc ========================== .. code-block:: python diff --git a/docs/source/doc/auto_control_file_process_doc/auto_control_file_process_doc.rst b/docs/source/Eng/doc/auto_control_file_process_doc/auto_control_file_process_doc.rst similarity index 95% rename from docs/source/doc/auto_control_file_process_doc/auto_control_file_process_doc.rst rename to docs/source/Eng/doc/auto_control_file_process_doc/auto_control_file_process_doc.rst index 968eb1a..f74e9f6 100644 --- a/docs/source/doc/auto_control_file_process_doc/auto_control_file_process_doc.rst +++ b/docs/source/Eng/doc/auto_control_file_process_doc/auto_control_file_process_doc.rst @@ -1,4 +1,4 @@ -AutoControlGUI File Process Doc +AutoControl File Process Doc ========================== diff --git a/docs/source/doc/auto_control_image_doc/auto_control_image_doc.rst b/docs/source/Eng/doc/auto_control_image_doc/auto_control_image_doc.rst similarity index 98% rename from docs/source/doc/auto_control_image_doc/auto_control_image_doc.rst rename to docs/source/Eng/doc/auto_control_image_doc/auto_control_image_doc.rst index 65c619d..1c47225 100644 --- a/docs/source/doc/auto_control_image_doc/auto_control_image_doc.rst +++ b/docs/source/Eng/doc/auto_control_image_doc/auto_control_image_doc.rst @@ -1,4 +1,4 @@ -AutoControlGUI Image Doc +AutoControl Image Doc ========================== .. code-block:: python diff --git a/docs/source/doc/auto_control_keyboard_doc/auto_control_keyboard_doc.rst b/docs/source/Eng/doc/auto_control_keyboard_doc/auto_control_keyboard_doc.rst similarity index 98% rename from docs/source/doc/auto_control_keyboard_doc/auto_control_keyboard_doc.rst rename to docs/source/Eng/doc/auto_control_keyboard_doc/auto_control_keyboard_doc.rst index 0f4e879..034d81f 100644 --- a/docs/source/doc/auto_control_keyboard_doc/auto_control_keyboard_doc.rst +++ b/docs/source/Eng/doc/auto_control_keyboard_doc/auto_control_keyboard_doc.rst @@ -1,4 +1,4 @@ -AutoControlGUI Keyboard Doc +AutoControl Keyboard Doc ========================== diff --git a/docs/source/doc/auto_control_mouse_doc/auto_control_mouse_doc.rst b/docs/source/Eng/doc/auto_control_mouse_doc/auto_control_mouse_doc.rst similarity index 94% rename from docs/source/doc/auto_control_mouse_doc/auto_control_mouse_doc.rst rename to docs/source/Eng/doc/auto_control_mouse_doc/auto_control_mouse_doc.rst index 80ea4a3..bda9af0 100644 --- a/docs/source/doc/auto_control_mouse_doc/auto_control_mouse_doc.rst +++ b/docs/source/Eng/doc/auto_control_mouse_doc/auto_control_mouse_doc.rst @@ -1,4 +1,4 @@ -AutoControlGUI Mouse Doc +AutoControl Mouse Doc ========================== @@ -30,7 +30,7 @@ AutoControlGUI Mouse Doc def press_mouse(mouse_keycode: [int, str], x: int = None, y: int = None): """ press mouse keycode on x, y - return keycode, x, y + return mouse_keycode, x, y :param mouse_keycode which mouse keycode we want to press :param x mouse click x position :param y mouse click y position @@ -39,7 +39,7 @@ AutoControlGUI Mouse Doc def release_mouse(mouse_keycode: [int, str], x: int = None, y: int = None): """ release mouse keycode on x, y - return keycode, x, y + return mouse_keycode, x, y :param mouse_keycode which mouse keycode we want to release :param x mouse click x position :param y mouse click y position @@ -48,7 +48,7 @@ AutoControlGUI Mouse Doc def click_mouse(mouse_keycode: [int, str], x: int = None, y: int = None): """ press and release mouse keycode on x, y - return keycode, x, y + return mouse_keycode, x, y :param mouse_keycode which mouse keycode we want to click :param x mouse click x position :param y mouse click y position diff --git a/docs/source/doc/auto_control_record_doc/auto_control_record_doc.rst b/docs/source/Eng/doc/auto_control_record_doc/auto_control_record_doc.rst similarity index 89% rename from docs/source/doc/auto_control_record_doc/auto_control_record_doc.rst rename to docs/source/Eng/doc/auto_control_record_doc/auto_control_record_doc.rst index 3375a85..971e88b 100644 --- a/docs/source/doc/auto_control_record_doc/auto_control_record_doc.rst +++ b/docs/source/Eng/doc/auto_control_record_doc/auto_control_record_doc.rst @@ -1,4 +1,4 @@ -AutoControlGUI Record Doc +AutoControl Record Doc ========================== diff --git a/docs/source/doc/auto_control_screen_doc/auto_control_screen_doc.rst b/docs/source/Eng/doc/auto_control_screen_doc/auto_control_screen_doc.rst similarity index 92% rename from docs/source/doc/auto_control_screen_doc/auto_control_screen_doc.rst rename to docs/source/Eng/doc/auto_control_screen_doc/auto_control_screen_doc.rst index 3c7a96b..4907187 100644 --- a/docs/source/doc/auto_control_screen_doc/auto_control_screen_doc.rst +++ b/docs/source/Eng/doc/auto_control_screen_doc/auto_control_screen_doc.rst @@ -1,4 +1,4 @@ -AutoControlGUI Screen Doc +AutoControl Screen Doc ========================== diff --git a/docs/source/doc/auto_control_test_record_doc/auto_control_test_record_doc.rst b/docs/source/Eng/doc/auto_control_test_record_doc/auto_control_test_record_doc.rst similarity index 93% rename from docs/source/doc/auto_control_test_record_doc/auto_control_test_record_doc.rst rename to docs/source/Eng/doc/auto_control_test_record_doc/auto_control_test_record_doc.rst index 5d95e8e..bca9005 100644 --- a/docs/source/doc/auto_control_test_record_doc/auto_control_test_record_doc.rst +++ b/docs/source/Eng/doc/auto_control_test_record_doc/auto_control_test_record_doc.rst @@ -1,4 +1,4 @@ -AutoControlGUI Test Record Doc +AutoControl Test Record Doc ========================== diff --git a/docs/source/doc/doc_index.rst b/docs/source/Eng/doc/doc_index.rst similarity index 100% rename from docs/source/doc/doc_index.rst rename to docs/source/Eng/doc/doc_index.rst diff --git a/docs/source/doc/generate_html_doc/generate_html_doc.rst b/docs/source/Eng/doc/generate_html_doc/generate_html_doc.rst similarity index 67% rename from docs/source/doc/generate_html_doc/generate_html_doc.rst rename to docs/source/Eng/doc/generate_html_doc/generate_html_doc.rst index 0b0fb27..897684a 100644 --- a/docs/source/doc/generate_html_doc/generate_html_doc.rst +++ b/docs/source/Eng/doc/generate_html_doc/generate_html_doc.rst @@ -1,6 +1,6 @@ -========================== -AutoControlGUI Generate Html Report Doc -========================== +====================================== +AutoControl Generate Html Report Doc +====================================== .. code-block:: python diff --git a/docs/source/Eng/eng_index.rst b/docs/source/Eng/eng_index.rst new file mode 100644 index 0000000..47406d0 --- /dev/null +++ b/docs/source/Eng/eng_index.rst @@ -0,0 +1,9 @@ +==================================== +AutoControl ENG DOC +==================================== + +.. toctree:: + :maxdepth: 4 + + example/example_index.rst + doc/doc_index.rst \ No newline at end of file diff --git a/docs/source/example/critical_exit_example/critical_exit.rst b/docs/source/Eng/example/critical_exit_example/critical_exit.rst similarity index 97% rename from docs/source/example/critical_exit_example/critical_exit.rst rename to docs/source/Eng/example/critical_exit_example/critical_exit.rst index 9d3d56e..c8fc803 100644 --- a/docs/source/example/critical_exit_example/critical_exit.rst +++ b/docs/source/Eng/example/critical_exit_example/critical_exit.rst @@ -1,4 +1,4 @@ -AutoControlGUI Critical Exit +AutoControl Critical Exit ========================== | critical exit diff --git a/docs/source/example/editor_example/editor.rst b/docs/source/Eng/example/editor_example/editor.rst similarity index 100% rename from docs/source/example/editor_example/editor.rst rename to docs/source/Eng/example/editor_example/editor.rst diff --git a/docs/source/example/example_index.rst b/docs/source/Eng/example/example_index.rst similarity index 100% rename from docs/source/example/example_index.rst rename to docs/source/Eng/example/example_index.rst diff --git a/docs/source/example/executor_example/execute_action.rst b/docs/source/Eng/example/executor_example/execute_action.rst similarity index 99% rename from docs/source/example/executor_example/execute_action.rst rename to docs/source/Eng/example/executor_example/execute_action.rst index 62b09ab..be2dbb2 100644 --- a/docs/source/example/executor_example/execute_action.rst +++ b/docs/source/Eng/example/executor_example/execute_action.rst @@ -1,5 +1,5 @@ ======================== -AutoControlGUI Execute action +AutoControl Execute action ======================== | you can use write_action_json to save action file diff --git a/docs/source/example/generate_html_example/generate_html_example.rst b/docs/source/Eng/example/generate_html_example/generate_html_example.rst similarity index 97% rename from docs/source/example/generate_html_example/generate_html_example.rst rename to docs/source/Eng/example/generate_html_example/generate_html_example.rst index c7ef4c1..91a43f2 100644 --- a/docs/source/example/generate_html_example/generate_html_example.rst +++ b/docs/source/Eng/example/generate_html_example/generate_html_example.rst @@ -1,5 +1,5 @@ ======================== -AutoControlGUI Generate Html Example +AutoControl Generate Html Example ======================== .. code-block:: python diff --git a/docs/source/example/image_detect_example/image_detect.rst b/docs/source/Eng/example/image_detect_example/image_detect.rst similarity index 98% rename from docs/source/example/image_detect_example/image_detect.rst rename to docs/source/Eng/example/image_detect_example/image_detect.rst index 52f333a..e729a7c 100644 --- a/docs/source/example/image_detect_example/image_detect.rst +++ b/docs/source/Eng/example/image_detect_example/image_detect.rst @@ -1,5 +1,5 @@ ======================== -AutoControlGUI ImageDetect +AutoControl ImageDetect ======================== | this example is screenshot and then check screenshot image is exist? diff --git a/docs/source/example/installation_example/installation.rst b/docs/source/Eng/example/installation_example/installation.rst similarity index 96% rename from docs/source/example/installation_example/installation.rst rename to docs/source/Eng/example/installation_example/installation.rst index c74d446..2f5448e 100644 --- a/docs/source/example/installation_example/installation.rst +++ b/docs/source/Eng/example/installation_example/installation.rst @@ -1,5 +1,5 @@ ============================== -AutoControlGUI Installation +AutoControl Installation ============================== .. code-block:: python diff --git a/docs/source/example/keyboard_example/keyboard.rst b/docs/source/Eng/example/keyboard_example/keyboard.rst similarity index 99% rename from docs/source/example/keyboard_example/keyboard.rst rename to docs/source/Eng/example/keyboard_example/keyboard.rst index df2aecd..a699bc7 100644 --- a/docs/source/example/keyboard_example/keyboard.rst +++ b/docs/source/Eng/example/keyboard_example/keyboard.rst @@ -1,5 +1,5 @@ ======================== -AutoControlGUI Keyboard +AutoControl Keyboard ======================== | Keyboard type diff --git a/docs/source/example/mouse_example/mouse.rst b/docs/source/Eng/example/mouse_example/mouse.rst similarity index 97% rename from docs/source/example/mouse_example/mouse.rst rename to docs/source/Eng/example/mouse_example/mouse.rst index 8bcc328..c24cdcf 100644 --- a/docs/source/example/mouse_example/mouse.rst +++ b/docs/source/Eng/example/mouse_example/mouse.rst @@ -1,5 +1,5 @@ ======================== -AutoControlGUI Mouse +AutoControl Mouse ======================== | Get location diff --git a/docs/source/example/record_example/record.rst b/docs/source/Eng/example/record_example/record.rst similarity index 98% rename from docs/source/example/record_example/record.rst rename to docs/source/Eng/example/record_example/record.rst index b05f94f..21ecad6 100644 --- a/docs/source/example/record_example/record.rst +++ b/docs/source/Eng/example/record_example/record.rst @@ -1,5 +1,5 @@ ======================== -AutoControlGUI Record +AutoControl Record ======================== | macos can't use record but can use execute action diff --git a/docs/source/example/screen_example/screen.rst b/docs/source/Eng/example/screen_example/screen.rst similarity index 96% rename from docs/source/example/screen_example/screen.rst rename to docs/source/Eng/example/screen_example/screen.rst index c7004cd..847f7a8 100644 --- a/docs/source/example/screen_example/screen.rst +++ b/docs/source/Eng/example/screen_example/screen.rst @@ -1,5 +1,5 @@ ======================== -AutoControlGUI Screen +AutoControl Screen ======================== | Check screen width and height diff --git a/docs/source/Zh/doc/auto_control_critical_exit_doc/auto_control_critical_exit_doc.rst b/docs/source/Zh/doc/auto_control_critical_exit_doc/auto_control_critical_exit_doc.rst new file mode 100644 index 0000000..d765bb6 --- /dev/null +++ b/docs/source/Zh/doc/auto_control_critical_exit_doc/auto_control_critical_exit_doc.rst @@ -0,0 +1,35 @@ +==================================================== +AutoControl 緊急退出 文件 +==================================================== + +.. code-block:: python + + class CriticalExit(Thread): + "當程式需要緊急退出時可使用此類別" + + def __init__(self, default_daemon: bool = True): + """ + 預設使用鍵盤 F7 來緊急中斷 + 是否隨著主程式關閉監聽 預設 True + :param default_daemon bool thread setDaemon + """ + + def set_critical_key(self, keycode: [int, str] = None): + """ + 設置中斷按鈕用 + keycode 為中斷的偵測按鈕 + :param keycode interrupt key + """ + + def run(self): + """ + 本質上還是thread + listener keycode _exit_check_key to interrupt + """ + + def init_critical_exit(self): + """ + 應該使用這方法開始監聽而不是原始 thread start + should only use this to start critical exit + may this function will add more + """ diff --git a/docs/source/Zh/doc/auto_control_executor_doc/auto_control_executor_doc.rst b/docs/source/Zh/doc/auto_control_executor_doc/auto_control_executor_doc.rst new file mode 100644 index 0000000..7cf27aa --- /dev/null +++ b/docs/source/Zh/doc/auto_control_executor_doc/auto_control_executor_doc.rst @@ -0,0 +1,78 @@ +==================================================== +AutoControl 執行器 文件 +==================================================== + +.. code-block:: python + + def execute_action(action_list: list): + """ + 執行所有在 list 裡的指令 + :param action_list the list include action + for loop the list and execute action + """ + + """ + 執行範例 可以使用 指令檔(json) 或是程式給予資料方式 + 指令檔適合已經固定化的測試流程 (當然也可以用程式產生) 使用者取捨使用 + 指令檔格式如下所示 example_list (不同平台keycode不同,請注意) + 程式格式也使用一樣的方式 + Executor example + on program or action file + use format like bottom + [function_name, {param: value,...}] + if no param use [function_name] + """ + from je_auto_control import execute_action + from je_auto_control import test_record + "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): + """ + 讀取json指令檔用 + use to read action file + :param json_file_path json file's path to read + """ + + def write_action_json(json_save_path: str, action_json: list): + """ + 儲存json指令檔用 + use to save action file + :param json_save_path json save path + :param action_json the json str include action to write + """ + +.. code-block:: python + + def execute_files(execute_files_list: list): + """ + 執行所有在list裡的指令檔 循序讀取然後執行 + execute_files_list 含所有要執行指令檔路徑的 list + :param execute_files_list: list include execute files path + :return: every execute detail as list + """ diff --git a/docs/source/Zh/doc/auto_control_file_process_doc/auto_control_file_process_doc.rst b/docs/source/Zh/doc/auto_control_file_process_doc/auto_control_file_process_doc.rst new file mode 100644 index 0000000..84209a1 --- /dev/null +++ b/docs/source/Zh/doc/auto_control_file_process_doc/auto_control_file_process_doc.rst @@ -0,0 +1,23 @@ +==================================================== +AutoControl 檔案處理 文件 +==================================================== + + +.. code-block:: python + + def get_dir_files_as_list(dir_path: str = getcwd(), default_search_file_extension: str = ".json"): + """ + 取得指定資料夾路徑下的 所有 default_search_file_extension 附檔名的檔案的 list + 可以跟 執行器 模塊的 execute_files 一起使用 + get dir file when end with default_search_file_extension + dir_path 是要搜尋檔案的資料夾路徑 + :param dir_path: which dir we want to walk and get file list + default_search_file_extension 搜尋的附檔名 + :param default_search_file_extension: which extension we want to search + :return: [] if nothing searched or [file1, file2.... files] file was searched + """ + return [ + abspath(join(dir_path, file)) for root, dirs, files in walk(dir_path) + for file in files + if file.endswith(default_search_file_extension.lower()) + ] \ No newline at end of file diff --git a/docs/source/Zh/doc/auto_control_image_doc/auto_control_image_doc.rst b/docs/source/Zh/doc/auto_control_image_doc/auto_control_image_doc.rst new file mode 100644 index 0000000..212a1a0 --- /dev/null +++ b/docs/source/Zh/doc/auto_control_image_doc/auto_control_image_doc.rst @@ -0,0 +1,50 @@ +==================================================== +AutoControl 圖片處理 文件 +==================================================== + +.. code-block:: python + + def locate_all_image(image, detect_threshold: [float, int] = 1, draw_image: bool = False, **kwargs): + """ + 定位所有一樣的圖片 並回傳所有圖片的 list + use to locate all image that detected and then return detected images list + 給予圖片路徑或者給予 PIL 的 ImageGrab.grab() + :param image which image we want to find on screen (png or PIL ImageGrab.grab()) + 偵測辨別度 0.0 ~ 1.0 1.0 是絕對相同 + :param detect_threshold detect precision 0.0 ~ 1.0; 1 is absolute equal (float or int) + 是否劃出偵測到圖片的範圍 + :param draw_image draw detect tag on return image (bool) + """ + + def locate_image_center(image, detect_threshold: [float, int] = 1, draw_image: bool = False, **kwargs): + """ + 定位圖片並取得其中心點 + use to locate image and return image center position + 給予圖片路徑或者給予 PIL 的 ImageGrab.grab() + :param image which image we want to find on screen (png or PIL ImageGrab.grab()) + 偵測辨別度 0.0 ~ 1.0 1.0 是絕對相同 + :param detect_threshold detect precision 0.0 ~ 1.0; 1 is absolute equal (float or int) + 是否劃出偵測到圖片的範圍 + :param draw_image draw detect tag on return image (bool) + """ + + def locate_and_click(image, mouse_keycode: [int, str], detect_threshold: [float, int] = 1, draw_image: bool = False, **kwargs): + """ + 定位圖片並點擊其中心點 + use to locate image and click image center position and the return image center position + :param image which image we want to find on screen (png or PIL ImageGrab.grab()) + :param mouse_keycode which mouse keycode we want to click + :param detect_threshold detect precision 0.0 ~ 1.0; 1 is absolute equal (float or int) + :param draw_image draw detect tag on return image (bool) + """ + + def screenshot(file_path: str = None, region: list = None): + """ + 截圖並存檔 可指定範圍 + use to get now screen image return image + 存檔路徑 + :param file_path save screenshot path (None is no save) + 截圖範圍 + :param region screenshot region (screenshot region on screen) + """ + diff --git a/docs/source/Zh/doc/auto_control_keyboard_doc/auto_control_keyboard_doc.rst b/docs/source/Zh/doc/auto_control_keyboard_doc/auto_control_keyboard_doc.rst new file mode 100644 index 0000000..294271d --- /dev/null +++ b/docs/source/Zh/doc/auto_control_keyboard_doc/auto_control_keyboard_doc.rst @@ -0,0 +1,70 @@ +==================================================== +AutoControl 鍵盤控制 文件 +==================================================== + + +.. code-block:: python + + def press_key(keycode: [int, str], is_shift: bool = False): + """ + 按下鍵盤按鍵 keycode 或是 字串 回傳傳入的字串 傳入一個以上會引發錯誤 + use to press a key still press to use release key + or use critical exit + return keycode + 哪個按鍵想按下 + :param keycode which keycode we want to press + 是否按著 shift + :param is_shift press shift True or False + """ + + def release_key(keycode: [int, str], is_shift: bool = False): + """ + 放開鍵盤按鍵 keycode 或是 字串 回傳傳入的字串 傳入一個以上會引發錯誤 + use to release pressed key return keycode + 哪個按鍵想放開 + :param keycode which keycode we want to release + 是否按著 shift + :param is_shift press shift True or False + """ + + def type_key(keycode: [int, str], is_shift: bool = False): + """ + 按下跟放開鍵盤 (類似正常使用) + press and release key return keycode + 哪個按鍵想點擊 + :param keycode which keycode we want to type + 是否按著 shift + :param is_shift press shift True or False + """ + + def check_key_is_press(keycode: [int, str]): + """ + 檢查鍵盤按鍵是否按下 + use to check key is press return True or False + 要檢查的按鍵 + :param keycode check key is press or not + """ + + def write(write_string: str, is_shift: bool = False): + """ + 對每個傳入的字元進行 type_key (按下與釋放的動作) + use to press and release whole we get this function str + 回傳有成功 type_key 的按鍵 + return all press and release str + 字串來遍歷執行 type_key + :param write_string while string not on write_string+1 type_key(string) + 是否按著 shift + :param is_shift press shift True or False + """ + + def hotkey(key_code_list: list, is_shift: bool = False): + """ + 對傳入的按鍵進行 press_key 並反著釋放 + use to press and release all key on key_code_list + then reverse list press and release again + 回傳按下的 字串 以及釋放的字串 + return [press_str_list, release_str_list] + list 包含想按下與釋放的 按鍵 + :param key_code_list press and release all key on list and reverse + :param is_shift press shift True or False + """ \ No newline at end of file diff --git a/docs/source/Zh/doc/auto_control_mouse_doc/auto_control_mouse_doc.rst b/docs/source/Zh/doc/auto_control_mouse_doc/auto_control_mouse_doc.rst new file mode 100644 index 0000000..b382728 --- /dev/null +++ b/docs/source/Zh/doc/auto_control_mouse_doc/auto_control_mouse_doc.rst @@ -0,0 +1,92 @@ +========================== +AutoControl 滑鼠控制 文件 +========================== + + +.. code-block:: python + + def mouse_preprocess(mouse_keycode: [int, str], x: int, y: int): + """ + 滑鼠的前處理函數 使用者通常不會用到 + check mouse keycode is verified or not + and then check current mouse position + 如果使用且沒有設定 x y 那就設定 x y 為目前位置 + if x or y is None set x, y is current position + mouse_keycode 想使用的滑鼠按鍵 + :param mouse_keycode which mouse keycode we want to click + 滑鼠 x 座標 + :param x mouse click x position + 滑鼠 y 座標 + :param y mouse click y position + """ + + def position(): + """ + 取得滑鼠目前 x y + get mouse current position + 回傳目前 x y + return mouse_x, mouse_y + """ + + def set_position(x: int, y: int): + """ + 設置滑鼠 x y + :param x set mouse position x + :param y set mouse position y + return x, y + """ + + def press_mouse(mouse_keycode: [int, str], x: int = None, y: int = None): + """ + 按下滑鼠按鍵 可選擇座標 + press mouse keycode on x, y + return mouse_keycode, x, y + 哪個按鍵想按下 + :param mouse_keycode which mouse keycode we want to press + :param x mouse press x position + :param y mouse press y position + """ + + def release_mouse(mouse_keycode: [int, str], x: int = None, y: int = None): + """ + 放開滑鼠按鍵 可選擇座標 + release mouse keycode on x, y + 回傳 mouse_keycode x y + return mouse_keycode, x, y + 想釋放的按鍵 + :param mouse_keycode which mouse keycode we want to release + 滑鼠釋放的位置 x 座標 + :param x mouse release x position + 滑鼠釋放的位置 y 座標 + :param y mouse release y position + """ + + def click_mouse(mouse_keycode: [int, str], x: int = None, y: int = None): + """ + 點擊與放開滑鼠按鍵 可選擇座標 + press and release mouse keycode on x, y + 回傳 傳入 mouse_keycode, x, y + return keycode, x, y + 想點擊的按鍵 + :param mouse_keycode which mouse keycode we want to click + 滑鼠點擊的位置 x 座標 + :param x mouse click x position + 滑鼠點擊的位置 y 座標 + :param y mouse click y position + """ + + def scroll(scroll_value: int, x: int = None, y: int = None, scroll_direction: str = "scroll_down"): + """" + 滾動滑鼠滾輪 + :param scroll_value scroll count + 滑鼠滾動的位置 x 座標 + :param x mouse scroll x position + 滑鼠滾動的位置 y 座標 + :param y mouse scroll y position + 方向 + :param scroll_direction which direction we want + scroll_direction = scroll_up : direction up + scroll_direction = scroll_down : direction down + scroll_direction = scroll_left : direction left + scroll_direction = scroll_right : direction right + """ diff --git a/docs/source/Zh/doc/auto_control_record_doc/auto_control_record_doc.rst b/docs/source/Zh/doc/auto_control_record_doc/auto_control_record_doc.rst new file mode 100644 index 0000000..b543be2 --- /dev/null +++ b/docs/source/Zh/doc/auto_control_record_doc/auto_control_record_doc.rst @@ -0,0 +1,18 @@ +========================== +AutoControl 紀錄 文件 +========================== + + +.. code-block:: python + + def record(): + """ + 開始記錄所有鍵盤及滑鼠的動作以便之後回放 + start record keyboard and mouse event until stop_record + """ + + def stop_record(): + """ + 停止記錄所有鍵盤及滑鼠的動作 + stop current record + """ diff --git a/docs/source/Zh/doc/auto_control_screen_doc/auto_control_screen_doc.rst b/docs/source/Zh/doc/auto_control_screen_doc/auto_control_screen_doc.rst new file mode 100644 index 0000000..ef12536 --- /dev/null +++ b/docs/source/Zh/doc/auto_control_screen_doc/auto_control_screen_doc.rst @@ -0,0 +1,22 @@ +==================================================== +AutoControl 螢幕操作 文件 +==================================================== + + +.. code-block:: python + + def size(): + """ + 取得目前螢幕 pixel 大小 + get screen size + """ + + def screenshot(file_path: str = None, region: list = None): + """ + 截圖 可選擇截圖區域 + use to capture current screen image + 存檔路徑 + :param file_path screenshot file save path + 截圖區域 + :param region screenshot region + """ diff --git a/docs/source/Zh/doc/auto_control_test_record_doc/auto_control_test_record_doc.rst b/docs/source/Zh/doc/auto_control_test_record_doc/auto_control_test_record_doc.rst new file mode 100644 index 0000000..d0795c8 --- /dev/null +++ b/docs/source/Zh/doc/auto_control_test_record_doc/auto_control_test_record_doc.rst @@ -0,0 +1,24 @@ +==================================================== +AutoControlGUI 測試紀錄 文件 +==================================================== + + +.. code-block:: python + + """ + 只是一個紀錄成功與失敗的列別 使用者可能不會用到 + just a data class use to record success and failure + """ + class TestRecord(object): + + def __init__(self): + self.record_list = list() + self.error_record_list = list() + + def clean_record(self): + self.record_list = list() + self.error_record_list = list() + + + test_record = TestRecord() + diff --git a/docs/source/Zh/doc/doc_index.rst b/docs/source/Zh/doc/doc_index.rst new file mode 100644 index 0000000..c171f75 --- /dev/null +++ b/docs/source/Zh/doc/doc_index.rst @@ -0,0 +1,17 @@ +================== +Doc +================== + +.. toctree:: + :maxdepth: 4 + + auto_control_image_doc/auto_control_image_doc.rst + auto_control_keyboard_doc/auto_control_keyboard_doc.rst + auto_control_mouse_doc/auto_control_mouse_doc.rst + auto_control_critical_exit_doc/auto_control_critical_exit_doc.rst + auto_control_executor_doc/auto_control_executor_doc.rst + auto_control_record_doc/auto_control_record_doc.rst + auto_control_screen_doc/auto_control_screen_doc.rst + auto_control_test_record_doc/auto_control_test_record_doc.rst + generate_html_doc/generate_html_doc.rst + auto_control_file_process_doc/auto_control_file_process_doc.rst diff --git a/docs/source/Zh/doc/generate_html_doc/generate_html_doc.rst b/docs/source/Zh/doc/generate_html_doc/generate_html_doc.rst new file mode 100644 index 0000000..28a392c --- /dev/null +++ b/docs/source/Zh/doc/generate_html_doc/generate_html_doc.rst @@ -0,0 +1,19 @@ +==================================================== +AutoControl HTML報告產生器文件 +==================================================== + + +.. code-block:: python + + def generate_html(html_name: str = "default_name"): + """ + 產生 HTML 報告使用 + this function will create and save html report on current folder + 產生的 HTML File 名字 + :param html_name: save html file name + 完整的 HTML 字串 + :return: html_string + """ + + + diff --git a/docs/source/Zh/example/critical_exit_example/critical_exit.rst b/docs/source/Zh/example/critical_exit_example/critical_exit.rst new file mode 100644 index 0000000..3eea8c0 --- /dev/null +++ b/docs/source/Zh/example/critical_exit_example/critical_exit.rst @@ -0,0 +1,40 @@ +==================================================== +AutoControl Critical Exit +==================================================== + +| 緊急退出 +| 如果需要在某些時候緊急退出可以使用此範例 +| 當按下設定的退出鍵時將會退出程式 +| 這個範例展示如何使用緊急退出 + +.. code-block:: python + + from je_auto_control import CriticalExit + from je_auto_control import keys_table + from je_auto_control import press_key + try: + """ + 預設緊急退出鍵為F7 + """ + critical_exit_thread = CriticalExit() + """ + 可以設置為任何在 keys_table 裡的按鍵 + 這裡設置為 F2 + """ + print(keys_table.keys()) + critical_exit_thread.set_critical_key("f2") + """ + 開始監聽 緊急退出鍵 + """ + critical_exit_thread.init_critical_exit() + + """ + 這裡將會退出 當函數觸動系統模擬使用者按下F2 + """ + while True: + press_key("f2") + except KeyboardInterrupt: + pass + + + diff --git a/docs/source/Zh/example/editor_example/editor.rst b/docs/source/Zh/example/editor_example/editor.rst new file mode 100644 index 0000000..c7aea22 --- /dev/null +++ b/docs/source/Zh/example/editor_example/editor.rst @@ -0,0 +1,18 @@ +========================== +Editor +========================== + +| 需要編輯器的話 有提供 +| Github : https://github.com/JE-Chen/je_editor + +.. code-block:: python + + pip install je_editor + + +.. code-block:: python + + from je_editor import start_editor + + start_editor() + diff --git a/docs/source/Zh/example/example_index.rst b/docs/source/Zh/example/example_index.rst new file mode 100644 index 0000000..1c46933 --- /dev/null +++ b/docs/source/Zh/example/example_index.rst @@ -0,0 +1,17 @@ +================== +Example +================== + +.. toctree:: + :maxdepth: 4 + + installation_example/installation.rst + critical_exit_example/critical_exit.rst + mouse_example/mouse.rst + keyboard_example/keyboard.rst + screen_example/screen.rst + image_detect_example/image_detect.rst + record_example/record.rst + executor_example/execute_action.rst + editor_example/editor.rst + generate_html_example/generate_html_example.rst \ No newline at end of file diff --git a/docs/source/Zh/example/executor_example/execute_action.rst b/docs/source/Zh/example/executor_example/execute_action.rst new file mode 100644 index 0000000..ce56206 --- /dev/null +++ b/docs/source/Zh/example/executor_example/execute_action.rst @@ -0,0 +1,90 @@ +================================================ +AutoControl 執行器範例 +================================================ + +| 可以使用 write_action_json 來儲存指令檔 +| 然後可以使用 read_action_json 來讀取指令檔 +| 這個範例是 讀取 及 儲存 指令檔 +.. code-block:: python + + import os + import json + + + from je_auto_control import read_action_json + from je_auto_control import write_action_json + test_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}], + ] + test_dumps_json = json.dumps(test_list) + print(test_dumps_json) + test_loads_json = json.loads(test_dumps_json) + print(test_loads_json) + list(test_loads_json) + + write_action_json(os.getcwd() + "/test.json", test_dumps_json) + read_json = read_action_json(os.getcwd() + "/test.json") + print(read_json) + + +| 可以直接使用 execute_action 加 list 含指令檔的方式 +| 這個範例使用 execute_action + test_record +.. code-block:: python + + import sys + + from je_auto_control import execute_action + from je_auto_control import test_record + + test_list = None + if sys.platform in ["win32", "cygwin", "msys"]: + test_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}], + ["type_key", {"mouse_keycode": "dwadwawda", "dwadwad": 500, "wdawddwawad": 500}], + ] + + elif sys.platform in ["linux", "linux2"]: + test_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}], + ] + elif sys.platform in ["darwin"]: + test_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}], + ] + print("\n\n") + execute_action(test_list) + + +.. code-block:: python + + """ + 取得 當前資料夾所有指令檔並執行的範例 + get current dir all execute file(json file) list and execute list of file + """ + import os + + from je_auto_control import get_dir_files_as_list + from je_auto_control import execute_files + files_list = get_dir_files_as_list(os.getcwd()) + print(files_list) + if files_list is not None: + execute_files(files_list) + diff --git a/docs/source/Zh/example/generate_html_example/generate_html_example.rst b/docs/source/Zh/example/generate_html_example/generate_html_example.rst new file mode 100644 index 0000000..d7240d3 --- /dev/null +++ b/docs/source/Zh/example/generate_html_example/generate_html_example.rst @@ -0,0 +1,47 @@ +======================== +AutoControl 產生 HTML 報告 +======================== + +.. code-block:: python + + import sys + + from je_auto_control import test_record + from je_auto_control import press_key + from je_auto_control import release_key + from je_auto_control import write + from je_auto_control import keys_table + from je_auto_control import generate_html + + # init test_record to record test detail + test_record.init_total_record = True + + print(keys_table.keys()) + # do something + press_key("shift") + write("123456789") + press_key("return") + release_key("return") + assert (write("abcdefghijklmnopqrstuvwxyz") == "abcdefghijklmnopqrstuvwxyz") + release_key("shift") + press_key("return") + release_key("return") + 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 + try: + assert (write("?123456789") == "123456789") + except Exception as error: + print(repr(error), file=sys.stderr) + # this write will print one error -> keyboard write error can't find key : ! and write remain string + try: + write("!#@L@#{@#PL#{!@#L{!#{|##PO}!@#O@!O#P!)KI#O_!K") + except Exception as error: + print(repr(error), file=sys.stderr) + + print(test_record.total_record_list) + # html name is test.html and this html will recode all test detail + # if test_record.init_total_record = True + generate_html("test") \ No newline at end of file diff --git a/docs/source/Zh/example/image_detect_example/image_detect.rst b/docs/source/Zh/example/image_detect_example/image_detect.rst new file mode 100644 index 0000000..be63c96 --- /dev/null +++ b/docs/source/Zh/example/image_detect_example/image_detect.rst @@ -0,0 +1,53 @@ +======================== +AutoControl ImageDetect +======================== + +| 這個範例會截圖並判斷截圖是否存在 + +.. code-block:: python + + import time + from je_auto_control import screenshot + from je_auto_control import locate_image_center + + time.sleep(2) + """ + detect_threshold 0~1 , 1 is absolute equal + draw_image, mark the find target + """ + image_data = locate_image_center(screenshot(), detect_threshold=0.9, draw_image=False) + print(image_data) + + +| 這個範例會截圖並判斷所有截圖是否存在 + +.. code-block:: python + + import time + from je_auto_control import screenshot + from je_auto_control import locate_all_image + + time.sleep(2) + """ + detect_threshold 0~1 , 1 is absolute equal + draw_image, mark the find target + """ + image_data = locate_all_image(screenshot(), detect_threshold=0.9, draw_image=False) + print(image_data) + +| 這個範例會截圖並判斷截圖是否存在並點擊 + +.. code-block:: python + + import time + from je_auto_control import screenshot + from je_auto_control import locate_and_click + + time.sleep(2) + """ + detect_threshold 0~1 , 1 is absolute equal + draw_image, mark the find target + """ + image_data = locate_and_click(screenshot(), detect_threshold=0.9, draw_image=False) + print(image_data) + ) diff --git a/docs/source/Zh/example/installation_example/installation.rst b/docs/source/Zh/example/installation_example/installation.rst new file mode 100644 index 0000000..7c2a376 --- /dev/null +++ b/docs/source/Zh/example/installation_example/installation.rst @@ -0,0 +1,30 @@ +============================== +AutoControl 安裝指南 +============================== +.. code-block:: python + + pip install je_auto_control + +* Python & pip require version + * Python 3.5 & up + * pip 19.3 & up + +* Dev env + * windows 11 + * osx 11 big sur + * ubuntu 20.0.4 + +| 如果想要在樹梅派使用 +.. code-block:: markdown + + sudo apt-get install python3 + pip3 install je_auto_control + sudo apt-get install libcblas-dev + sudo apt-get install libhdf5-dev + sudo apt-get install libhdf5-serial-dev + sudo apt-get install libatlas-base-dev + sudo apt-get install libjasper-dev + sudo apt-get install libqtgui4 + sudo apt-get install libqt4-test + pip3 install -U pillow + pip3 install -U numpy diff --git a/docs/source/Zh/example/keyboard_example/keyboard.rst b/docs/source/Zh/example/keyboard_example/keyboard.rst new file mode 100644 index 0000000..a256f5b --- /dev/null +++ b/docs/source/Zh/example/keyboard_example/keyboard.rst @@ -0,0 +1,127 @@ +======================== +AutoControl 鍵盤使用 +======================== + +| 鍵盤按下按鍵 +| type_key 將會按下跟放開按鍵 此範例會自動打出 TEST + +.. code-block:: python + + import time + + from je_auto_control import type_key + from je_auto_control import keys_table + + """ + check keys + """ + print(keys_table.keys()) + type_key("T") + type_key("E") + type_key("S") + type_key("T") + +| 檢查按鍵是否按下 +| check_key_is_press 函數將會檢查按鍵是否按下 並返回布林值 +.. code-block:: python + + import sys + + from je_auto_control import check_key_is_press + from je_auto_control import press_key + from je_auto_control import release_key + from je_auto_control import AutoControlException + + try: + """ + because os key_code not equal + """ + while True: + if sys.platform in ["win32", "cygwin", "msys"]: + press_key("A") + """ + windows key a or you can use check_key_is_press(ord("A")) + """ + if check_key_is_press("A"): + sys.exit(0) + elif sys.platform in ["darwin"]: + press_key("f5") + """ + osx key F5 + """ + if check_key_is_press(0x60): + sys.exit(0) + elif sys.platform in ["linux", "linux2"]: + press_key("a") + """ + linux key a + """ + if check_key_is_press(0): + sys.exit(0) + except AutoControlException: + raise AutoControlException + finally: + if sys.platform in ["win32", "cygwin", "msys"]: + release_key("A") + elif sys.platform in ["darwin"]: + release_key("f5") + elif sys.platform in ["linux", "linux2"]: + release_key("a") + + +| 鍵盤 write 函數 +| write 函數將會自動按下與釋放所有傳入的字串 + +.. code-block:: python + + import sys + + from je_auto_control import keys_table + from je_auto_control import press_key + from je_auto_control import release_key + from je_auto_control import write + + print(keys_table.keys()) + + press_key("shift") + write("123456789") + press_key("return") + release_key("return") + write("abcdefghijklmnopqrstuvwxyz") + release_key("shift") + press_key("return") + release_key("return") + write("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") + + +| Keyboard hotkey + +.. code-block:: python + + import sys + + from je_auto_control import hotkey + + if sys.platform in ["win32", "cygwin", "msys"]: + hotkey(["lcontrol", "a"]) + hotkey(["lcontrol", "c"]) + hotkey(["lcontrol", "v"]) + hotkey(["lcontrol", "v"]) + + elif sys.platform in ["darwin"]: + hotkey(["command", "a"]) + hotkey(["command", "c"]) + hotkey(["command", "v"]) + hotkey(["command", "v"]) + + elif sys.platform in ["linux", "linux2"]: + hotkey(["ctrl", "a"]) + hotkey(["ctrl", "c"]) + hotkey(["ctrl", "v"]) + hotkey(["ctrl", "v"]) diff --git a/docs/source/Zh/example/mouse_example/mouse.rst b/docs/source/Zh/example/mouse_example/mouse.rst new file mode 100644 index 0000000..c24cdcf --- /dev/null +++ b/docs/source/Zh/example/mouse_example/mouse.rst @@ -0,0 +1,44 @@ +======================== +AutoControl Mouse +======================== + +| Get location +| Set location +| Press and release mouse +| Click mouse +| Check mouse keys + +| in this example first we check now mouse position +| and then we set mouse position +| then we press and release mouse right and left +.. code-block:: python + + import time + + from je_auto_control import position + from je_auto_control import set_position + from je_auto_control import press_mouse + from je_auto_control import release_mouse + from je_auto_control import click_mouse + from je_auto_control import mouse_table + + time.sleep(1) + + print(position()) + set_position(809, 388) + + print(mouse_table.keys()) + + press_mouse("mouse_right") + release_mouse("mouse_right") + press_mouse("mouse_left") + release_mouse("mouse_left") + click_mouse("mouse_left") + +| Scroll mouse +| this example is scroll down mouse 100 unit +.. code-block:: python + + from je_auto_control import scroll + + scroll(100) \ No newline at end of file diff --git a/docs/source/Zh/example/record_example/record.rst b/docs/source/Zh/example/record_example/record.rst new file mode 100644 index 0000000..21ecad6 --- /dev/null +++ b/docs/source/Zh/example/record_example/record.rst @@ -0,0 +1,48 @@ +======================== +AutoControl Record +======================== + +| macos can't use record but can use execute action +| record keyboard and mouse event +| this example will auto type test and record will execute and type test +.. code-block:: python + + from time import sleep + + from je_auto_control import record + from je_auto_control import stop_record + from je_auto_control import type_key + from je_auto_control import execute_action + + """ + this program will type test two time + one time is type key one time is record + """ + record() + sleep(1) + print(type_key("t")) + print(type_key("e")) + print(type_key("s")) + print(type_key("t")) + sleep(2) + record_result = stop_record() + print(record_result) + execute_action(record_result) + sleep(2) + + +| record your mouse & keyboard event 5s + +.. code-block:: python + + from je_auto_control import record + from je_auto_control import stop_record + from je_auto_control import execute_action + + record() + from time import sleep + sleep(5) + record_result = stop_record() + print(record_result) + execute_action(record_result) + sleep(2) \ No newline at end of file diff --git a/docs/source/Zh/example/screen_example/screen.rst b/docs/source/Zh/example/screen_example/screen.rst new file mode 100644 index 0000000..847f7a8 --- /dev/null +++ b/docs/source/Zh/example/screen_example/screen.rst @@ -0,0 +1,41 @@ +======================== +AutoControl Screen +======================== + +| Check screen width and height + +.. code-block:: python + + """ + check screen width and height + """ + from je_auto_control import size + + print(size()) + +| Screenshot + +.. code-block:: python + + from je_auto_control import screenshot + + """ + choose screenshot region + """ + image = screenshot(region=[300, 400, 500, 600]) + + print(image) + + """ + screenshot and save + """ + image = screenshot("test.png") + + print(image) + + """ + only screenshot + """ + image = screenshot() + + print(image) \ No newline at end of file diff --git a/docs/source/Zh/zh_index.rst b/docs/source/Zh/zh_index.rst new file mode 100644 index 0000000..a578a3a --- /dev/null +++ b/docs/source/Zh/zh_index.rst @@ -0,0 +1,9 @@ +==================================== +AutoControl 繁體中文文件 +==================================== + +.. toctree:: + :maxdepth: 4 + + example/example_index.rst + doc/doc_index.rst \ No newline at end of file diff --git a/docs/source/index.rst b/docs/source/index.rst index 066f01b..bb638f5 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -5,8 +5,8 @@ AutoControlGUI_JE .. toctree:: :maxdepth: 4 - example/example_index.rst - doc/doc_index.rst + Eng/eng_index.rst + Zh/zh_index.rst | JE Auto Control as a tool for GUI Testing diff --git a/je_auto_control/__init__.py b/je_auto_control/__init__.py index 600edee..c5ae98c 100644 --- a/je_auto_control/__init__.py +++ b/je_auto_control/__init__.py @@ -2,29 +2,6 @@ import all wrapper function """ -__all__ = [ - "click_mouse", "mouse_table", "position", "press_mouse", "release_mouse", - "scroll", "set_position", "special_table", - "keys_table", "press_key", "release_key", "type_key", "check_key_is_press", - "write", "hotkey", - "size", "screenshot", - "locate_all_image", "locate_image_center", "locate_and_click", - "CriticalExit", - "AutoControlException", "AutoControlKeyboardException", - "AutoControlMouseException", "AutoControlCantFindKeyException", - "AutoControlScreenException", "ImageNotFoundException", - "AutoControlJsonActionException", "AutoControlRecordException", - "AutoControlActionNullException", "AutoControlActionException", - "record", "stop_record", - "read_action_json", "write_action_json", - "execute_action", "execute_files", "executor", "add_command_to_executor", - "multiprocess_timeout", "test_record_instance", - "screenshot", - "pil_screenshot", - "generate_html", - "get_dir_files_as_list", "create_template_dir", "start_autocontrol_socket_server" -] - # Critical from je_auto_control.utils.critical_exit.critcal_exit import CriticalExit from je_auto_control.utils.exception.exceptions import AutoControlActionException @@ -86,3 +63,26 @@ from je_auto_control.wrapper.auto_control_screen import screenshot # import screen from je_auto_control.wrapper.auto_control_screen import size + +__all__ = [ + "click_mouse", "mouse_table", "position", "press_mouse", "release_mouse", + "scroll", "set_position", "special_table", + "keys_table", "press_key", "release_key", "type_key", "check_key_is_press", + "write", "hotkey", + "size", "screenshot", + "locate_all_image", "locate_image_center", "locate_and_click", + "CriticalExit", + "AutoControlException", "AutoControlKeyboardException", + "AutoControlMouseException", "AutoControlCantFindKeyException", + "AutoControlScreenException", "ImageNotFoundException", + "AutoControlJsonActionException", "AutoControlRecordException", + "AutoControlActionNullException", "AutoControlActionException", + "record", "stop_record", + "read_action_json", "write_action_json", + "execute_action", "execute_files", "executor", "add_command_to_executor", + "multiprocess_timeout", "test_record_instance", + "screenshot", + "pil_screenshot", + "generate_html", + "get_dir_files_as_list", "create_template_dir", "start_autocontrol_socket_server" +] diff --git a/je_auto_control/utils/executor/action_executor.py b/je_auto_control/utils/executor/action_executor.py index a51182d..90a643c 100644 --- a/je_auto_control/utils/executor/action_executor.py +++ b/je_auto_control/utils/executor/action_executor.py @@ -1,11 +1,13 @@ import sys import types -from je_auto_control import check_key_is_press, position, press_mouse, release_mouse, click_mouse, scroll -from je_auto_control import locate_all_image, locate_and_click, locate_image_center -from je_auto_control import press_key, release_key, hotkey, type_key, write, record, stop_record -from je_auto_control import screenshot, size -from je_auto_control import set_position +from je_auto_control.wrapper.auto_control_keyboard import check_key_is_press +from je_auto_control.wrapper.auto_control_mouse import position, press_mouse, release_mouse, click_mouse, scroll +from je_auto_control.wrapper.auto_control_image import locate_all_image, locate_and_click, locate_image_center +from je_auto_control.wrapper.auto_control_keyboard import press_key, release_key, hotkey, type_key, write +from je_auto_control.wrapper.auto_control_record import record, stop_record +from je_auto_control.wrapper.auto_control_screen import screenshot, size +from je_auto_control.wrapper.auto_control_mouse import set_position from je_auto_control.utils.exception.exception_tag import action_is_null_error, add_command_exception_tag, \ executor_list_error from je_auto_control.utils.exception.exception_tag import cant_execute_action_error diff --git a/je_auto_control/windows/mouse/win32_ctype_mouse_control.py b/je_auto_control/windows/mouse/win32_ctype_mouse_control.py index f127c48..e8e5bd3 100644 --- a/je_auto_control/windows/mouse/win32_ctype_mouse_control.py +++ b/je_auto_control/windows/mouse/win32_ctype_mouse_control.py @@ -21,7 +21,7 @@ from je_auto_control.windows.core.utils.win32_vk import win32_XBUTTON2 from je_auto_control.windows.core.utils.win32_vk import win32_DOWN from je_auto_control.windows.core.utils.win32_vk import win32_XUP -from je_auto_control.windows.core.utils.win32_ctype_input import windll +from ctypes import windll from je_auto_control.windows.core.utils.win32_ctype_input import wintypes from je_auto_control.windows.core.utils.win32_vk import win32_WHEEL from je_auto_control.windows.core.utils.win32_ctype_input import ctypes diff --git a/je_auto_control/wrapper/auto_control_keyboard.py b/je_auto_control/wrapper/auto_control_keyboard.py index 6a1aef0..14e2385 100644 --- a/je_auto_control/wrapper/auto_control_keyboard.py +++ b/je_auto_control/wrapper/auto_control_keyboard.py @@ -35,7 +35,7 @@ def press_key(keycode: [int, str], is_shift: bool = False, skip_record: bool = F """ param = locals() try: - if isinstance(keycode, int): + if isinstance(keycode, str): try: keycode = keys_table.get(keycode) except AutoControlCantFindKeyException: @@ -73,7 +73,7 @@ def release_key(keycode: [int, str], is_shift: bool = False, skip_record: bool = """ param = locals() try: - if isinstance(keycode, int): + if isinstance(keycode, str): try: keycode = keys_table.get(keycode) except AutoControlCantFindKeyException: diff --git a/setup.py b/setup.py index f0d6f0d..0fa1768 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="je_auto_control", - version="0.0.110", + version="0.0.114", author="JE-Chen", author_email="zenmailman@gmail.com", description="auto testing",