Skip to content

Commit 42fbea4

Browse files
authored
Merge pull request #63 from JE-Chen/dev
Dev
2 parents 7fe7741 + 95b0917 commit 42fbea4

File tree

54 files changed

+1151
-212
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1151
-212
lines changed

.idea/workspace.xml

Lines changed: 69 additions & 153 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dev_setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="je_auto_control_dev",
8-
version="0.0.44",
8+
version="0.0.48",
99
author="JE-Chen",
1010
author_email="zenmailman@gmail.com",
1111
description="auto testing",

docs/source/doc/auto_control_critical_exit_doc/auto_control_critical_exit_doc.rst renamed to docs/source/Eng/doc/auto_control_critical_exit_doc/auto_control_critical_exit_doc.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
AutoControlGUI Critical Exit Doc
1+
AutoControl Critical Exit Doc
22
==========================
33

44
.. code-block:: python

docs/source/doc/auto_control_executor_doc/auto_control_executor_doc.rst renamed to docs/source/Eng/doc/auto_control_executor_doc/auto_control_executor_doc.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
AutoControlGUI Executor Doc
1+
AutoControl Executor Doc
22
==========================
33

44
.. code-block:: python

docs/source/doc/auto_control_file_process_doc/auto_control_file_process_doc.rst renamed to docs/source/Eng/doc/auto_control_file_process_doc/auto_control_file_process_doc.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
AutoControlGUI File Process Doc
1+
AutoControl File Process Doc
22
==========================
33

44

docs/source/doc/auto_control_image_doc/auto_control_image_doc.rst renamed to docs/source/Eng/doc/auto_control_image_doc/auto_control_image_doc.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
AutoControlGUI Image Doc
1+
AutoControl Image Doc
22
==========================
33

44
.. code-block:: python

docs/source/doc/auto_control_keyboard_doc/auto_control_keyboard_doc.rst renamed to docs/source/Eng/doc/auto_control_keyboard_doc/auto_control_keyboard_doc.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
AutoControlGUI Keyboard Doc
1+
AutoControl Keyboard Doc
22
==========================
33

44

docs/source/doc/auto_control_mouse_doc/auto_control_mouse_doc.rst renamed to docs/source/Eng/doc/auto_control_mouse_doc/auto_control_mouse_doc.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
AutoControlGUI Mouse Doc
1+
AutoControl Mouse Doc
22
==========================
33

44

@@ -30,7 +30,7 @@ AutoControlGUI Mouse Doc
3030
def press_mouse(mouse_keycode: [int, str], x: int = None, y: int = None):
3131
"""
3232
press mouse keycode on x, y
33-
return keycode, x, y
33+
return mouse_keycode, x, y
3434
:param mouse_keycode which mouse keycode we want to press
3535
:param x mouse click x position
3636
:param y mouse click y position
@@ -39,7 +39,7 @@ AutoControlGUI Mouse Doc
3939
def release_mouse(mouse_keycode: [int, str], x: int = None, y: int = None):
4040
"""
4141
release mouse keycode on x, y
42-
return keycode, x, y
42+
return mouse_keycode, x, y
4343
:param mouse_keycode which mouse keycode we want to release
4444
:param x mouse click x position
4545
:param y mouse click y position
@@ -48,7 +48,7 @@ AutoControlGUI Mouse Doc
4848
def click_mouse(mouse_keycode: [int, str], x: int = None, y: int = None):
4949
"""
5050
press and release mouse keycode on x, y
51-
return keycode, x, y
51+
return mouse_keycode, x, y
5252
:param mouse_keycode which mouse keycode we want to click
5353
:param x mouse click x position
5454
:param y mouse click y position

docs/source/doc/auto_control_record_doc/auto_control_record_doc.rst renamed to docs/source/Eng/doc/auto_control_record_doc/auto_control_record_doc.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
AutoControlGUI Record Doc
1+
AutoControl Record Doc
22
==========================
33

44

docs/source/doc/auto_control_screen_doc/auto_control_screen_doc.rst renamed to docs/source/Eng/doc/auto_control_screen_doc/auto_control_screen_doc.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
AutoControlGUI Screen Doc
1+
AutoControl Screen Doc
22
==========================
33

44

docs/source/doc/auto_control_test_record_doc/auto_control_test_record_doc.rst renamed to docs/source/Eng/doc/auto_control_test_record_doc/auto_control_test_record_doc.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
AutoControlGUI Test Record Doc
1+
AutoControl Test Record Doc
22
==========================
33

44

File renamed without changes.

docs/source/doc/generate_html_doc/generate_html_doc.rst renamed to docs/source/Eng/doc/generate_html_doc/generate_html_doc.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
==========================
2-
AutoControlGUI Generate Html Report Doc
3-
==========================
1+
======================================
2+
AutoControl Generate Html Report Doc
3+
======================================
44

55

66
.. code-block:: python

docs/source/Eng/eng_index.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
====================================
2+
AutoControl ENG DOC
3+
====================================
4+
5+
.. toctree::
6+
:maxdepth: 4
7+
8+
example/example_index.rst
9+
doc/doc_index.rst

docs/source/example/critical_exit_example/critical_exit.rst renamed to docs/source/Eng/example/critical_exit_example/critical_exit.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
AutoControlGUI Critical Exit
1+
AutoControl Critical Exit
22
==========================
33

44
| critical exit

docs/source/example/executor_example/execute_action.rst renamed to docs/source/Eng/example/executor_example/execute_action.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
========================
2-
AutoControlGUI Execute action
2+
AutoControl Execute action
33
========================
44

55
| you can use write_action_json to save action file

docs/source/example/generate_html_example/generate_html_example.rst renamed to docs/source/Eng/example/generate_html_example/generate_html_example.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
========================
2-
AutoControlGUI Generate Html Example
2+
AutoControl Generate Html Example
33
========================
44

55
.. code-block:: python

docs/source/example/image_detect_example/image_detect.rst renamed to docs/source/Eng/example/image_detect_example/image_detect.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
========================
2-
AutoControlGUI ImageDetect
2+
AutoControl ImageDetect
33
========================
44

55
| this example is screenshot and then check screenshot image is exist?

docs/source/example/installation_example/installation.rst renamed to docs/source/Eng/example/installation_example/installation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
==============================
2-
AutoControlGUI Installation
2+
AutoControl Installation
33
==============================
44
.. code-block:: python
55

docs/source/example/keyboard_example/keyboard.rst renamed to docs/source/Eng/example/keyboard_example/keyboard.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
========================
2-
AutoControlGUI Keyboard
2+
AutoControl Keyboard
33
========================
44

55
| Keyboard type

docs/source/example/mouse_example/mouse.rst renamed to docs/source/Eng/example/mouse_example/mouse.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
========================
2-
AutoControlGUI Mouse
2+
AutoControl Mouse
33
========================
44

55
| Get location

docs/source/example/record_example/record.rst renamed to docs/source/Eng/example/record_example/record.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
========================
2-
AutoControlGUI Record
2+
AutoControl Record
33
========================
44

55
| macos can't use record but can use execute action

docs/source/example/screen_example/screen.rst renamed to docs/source/Eng/example/screen_example/screen.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
========================
2-
AutoControlGUI Screen
2+
AutoControl Screen
33
========================
44

55
| Check screen width and height
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
====================================================
2+
AutoControl 緊急退出 文件
3+
====================================================
4+
5+
.. code-block:: python
6+
7+
class CriticalExit(Thread):
8+
"當程式需要緊急退出時可使用此類別"
9+
10+
def __init__(self, default_daemon: bool = True):
11+
"""
12+
預設使用鍵盤 F7 來緊急中斷
13+
是否隨著主程式關閉監聽 預設 True
14+
:param default_daemon bool thread setDaemon
15+
"""
16+
17+
def set_critical_key(self, keycode: [int, str] = None):
18+
"""
19+
設置中斷按鈕用
20+
keycode 為中斷的偵測按鈕
21+
:param keycode interrupt key
22+
"""
23+
24+
def run(self):
25+
"""
26+
本質上還是thread
27+
listener keycode _exit_check_key to interrupt
28+
"""
29+
30+
def init_critical_exit(self):
31+
"""
32+
應該使用這方法開始監聽而不是原始 thread start
33+
should only use this to start critical exit
34+
may this function will add more
35+
"""
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
====================================================
2+
AutoControl 執行器 文件
3+
====================================================
4+
5+
.. code-block:: python
6+
7+
def execute_action(action_list: list):
8+
"""
9+
執行所有在 list 裡的指令
10+
:param action_list the list include action
11+
for loop the list and execute action
12+
"""
13+
14+
"""
15+
執行範例 可以使用 指令檔(json) 或是程式給予資料方式
16+
指令檔適合已經固定化的測試流程 (當然也可以用程式產生) 使用者取捨使用
17+
指令檔格式如下所示 example_list (不同平台keycode不同,請注意)
18+
程式格式也使用一樣的方式
19+
Executor example
20+
on program or action file
21+
use format like bottom
22+
[function_name, {param: value,...}]
23+
if no param use [function_name]
24+
"""
25+
from je_auto_control import execute_action
26+
from je_auto_control import test_record
27+
"windows"
28+
example_list = [
29+
["type_key", {"keycode": 65}],
30+
["mouse_left", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
31+
["position"],
32+
["press_mouse", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
33+
["release_mouse", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}]
34+
]
35+
"macos"
36+
example_list = [
37+
["type_key", {"keycode": 0x00}],
38+
["mouse_left", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
39+
["position"],
40+
["press_mouse", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
41+
["release_mouse", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
42+
["type_key", {"mouse_keycode": "dwadwawda", "dwadwad": 500, "wdawddwawad": 500}]
43+
]
44+
"linux"
45+
example_list = [
46+
["type_key", {"keycode": 38}],
47+
["mouse_left", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
48+
["position"],
49+
["press_mouse", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
50+
["release_mouse", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
51+
["type_key", {"mouse_keycode": "dwadwawda", "dwadwad": 500, "wdawddwawad": 500}]
52+
]
53+
execute_action(example_list)
54+
55+
def read_action_json(json_file_path: str):
56+
"""
57+
讀取json指令檔用
58+
use to read action file
59+
:param json_file_path json file's path to read
60+
"""
61+
62+
def write_action_json(json_save_path: str, action_json: list):
63+
"""
64+
儲存json指令檔用
65+
use to save action file
66+
:param json_save_path json save path
67+
:param action_json the json str include action to write
68+
"""
69+
70+
.. code-block:: python
71+
72+
def execute_files(execute_files_list: list):
73+
"""
74+
執行所有在list裡的指令檔 循序讀取然後執行
75+
execute_files_list 含所有要執行指令檔路徑的 list
76+
:param execute_files_list: list include execute files path
77+
:return: every execute detail as list
78+
"""
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
====================================================
2+
AutoControl 檔案處理 文件
3+
====================================================
4+
5+
6+
.. code-block:: python
7+
8+
def get_dir_files_as_list(dir_path: str = getcwd(), default_search_file_extension: str = ".json"):
9+
"""
10+
取得指定資料夾路徑下的 所有 default_search_file_extension 附檔名的檔案的 list
11+
可以跟 執行器 模塊的 execute_files 一起使用
12+
get dir file when end with default_search_file_extension
13+
dir_path 是要搜尋檔案的資料夾路徑
14+
:param dir_path: which dir we want to walk and get file list
15+
default_search_file_extension 搜尋的附檔名
16+
:param default_search_file_extension: which extension we want to search
17+
:return: [] if nothing searched or [file1, file2.... files] file was searched
18+
"""
19+
return [
20+
abspath(join(dir_path, file)) for root, dirs, files in walk(dir_path)
21+
for file in files
22+
if file.endswith(default_search_file_extension.lower())
23+
]
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
====================================================
2+
AutoControl 圖片處理 文件
3+
====================================================
4+
5+
.. code-block:: python
6+
7+
def locate_all_image(image, detect_threshold: [float, int] = 1, draw_image: bool = False, **kwargs):
8+
"""
9+
定位所有一樣的圖片 並回傳所有圖片的 list
10+
use to locate all image that detected and then return detected images list
11+
給予圖片路徑或者給予 PIL 的 ImageGrab.grab()
12+
:param image which image we want to find on screen (png or PIL ImageGrab.grab())
13+
偵測辨別度 0.0 ~ 1.0 1.0 是絕對相同
14+
:param detect_threshold detect precision 0.0 ~ 1.0; 1 is absolute equal (float or int)
15+
是否劃出偵測到圖片的範圍
16+
:param draw_image draw detect tag on return image (bool)
17+
"""
18+
19+
def locate_image_center(image, detect_threshold: [float, int] = 1, draw_image: bool = False, **kwargs):
20+
"""
21+
定位圖片並取得其中心點
22+
use to locate image and return image center position
23+
給予圖片路徑或者給予 PIL 的 ImageGrab.grab()
24+
:param image which image we want to find on screen (png or PIL ImageGrab.grab())
25+
偵測辨別度 0.0 ~ 1.0 1.0 是絕對相同
26+
:param detect_threshold detect precision 0.0 ~ 1.0; 1 is absolute equal (float or int)
27+
是否劃出偵測到圖片的範圍
28+
:param draw_image draw detect tag on return image (bool)
29+
"""
30+
31+
def locate_and_click(image, mouse_keycode: [int, str], detect_threshold: [float, int] = 1, draw_image: bool = False, **kwargs):
32+
"""
33+
定位圖片並點擊其中心點
34+
use to locate image and click image center position and the return image center position
35+
:param image which image we want to find on screen (png or PIL ImageGrab.grab())
36+
:param mouse_keycode which mouse keycode we want to click
37+
:param detect_threshold detect precision 0.0 ~ 1.0; 1 is absolute equal (float or int)
38+
:param draw_image draw detect tag on return image (bool)
39+
"""
40+
41+
def screenshot(file_path: str = None, region: list = None):
42+
"""
43+
截圖並存檔 可指定範圍
44+
use to get now screen image return image
45+
存檔路徑
46+
:param file_path save screenshot path (None is no save)
47+
截圖範圍
48+
:param region screenshot region (screenshot region on screen)
49+
"""
50+

0 commit comments

Comments
 (0)