Skip to content

Commit

Permalink
Merge pull request #63 from JE-Chen/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
JE-Chen authored Nov 24, 2022
2 parents 7fe7741 + 95b0917 commit 42fbea4
Show file tree
Hide file tree
Showing 54 changed files with 1,151 additions and 212 deletions.
222 changes: 69 additions & 153 deletions .idea/workspace.xml

Large diffs are not rendered by default.

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.44",
version="0.0.48",
author="JE-Chen",
author_email="zenmailman@gmail.com",
description="auto testing",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
AutoControlGUI Critical Exit Doc
AutoControl Critical Exit Doc
==========================

.. code-block:: python
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
AutoControlGUI Executor Doc
AutoControl Executor Doc
==========================

.. code-block:: python
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
AutoControlGUI File Process Doc
AutoControl File Process Doc
==========================


Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
AutoControlGUI Image Doc
AutoControl Image Doc
==========================

.. code-block:: python
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
AutoControlGUI Keyboard Doc
AutoControl Keyboard Doc
==========================


Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
AutoControlGUI Mouse Doc
AutoControl Mouse Doc
==========================


Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
AutoControlGUI Record Doc
AutoControl Record Doc
==========================


Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
AutoControlGUI Screen Doc
AutoControl Screen Doc
==========================


Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
AutoControlGUI Test Record Doc
AutoControl Test Record Doc
==========================


Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
==========================
AutoControlGUI Generate Html Report Doc
==========================
======================================
AutoControl Generate Html Report Doc
======================================


.. code-block:: python
Expand Down
9 changes: 9 additions & 0 deletions docs/source/Eng/eng_index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
====================================
AutoControl ENG DOC
====================================

.. toctree::
:maxdepth: 4

example/example_index.rst
doc/doc_index.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
AutoControlGUI Critical Exit
AutoControl Critical Exit
==========================

| critical exit
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
========================
AutoControlGUI Execute action
AutoControl Execute action
========================

| you can use write_action_json to save action file
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
========================
AutoControlGUI Generate Html Example
AutoControl Generate Html Example
========================

.. code-block:: python
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
========================
AutoControlGUI ImageDetect
AutoControl ImageDetect
========================

| this example is screenshot and then check screenshot image is exist?
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
==============================
AutoControlGUI Installation
AutoControl Installation
==============================
.. code-block:: python
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
========================
AutoControlGUI Keyboard
AutoControl Keyboard
========================

| Keyboard type
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
========================
AutoControlGUI Mouse
AutoControl Mouse
========================

| Get location
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
========================
AutoControlGUI Record
AutoControl Record
========================

| macos can't use record but can use execute action
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
========================
AutoControlGUI Screen
AutoControl Screen
========================

| Check screen width and height
Expand Down
Original file line number Diff line number Diff line change
@@ -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
"""
Original file line number Diff line number Diff line change
@@ -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
"""
Original file line number Diff line number Diff line change
@@ -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())
]
Original file line number Diff line number Diff line change
@@ -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)
"""
Loading

0 comments on commit 42fbea4

Please sign in to comment.