Skip to content

Commit 9a9dada

Browse files
committed
add doc and test
add doc and test
1 parent 11c60e7 commit 9a9dada

File tree

26 files changed

+972
-15
lines changed

26 files changed

+972
-15
lines changed

.idea/workspace.xml

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

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
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
AutoControlGUI Critical Exit Doc
2+
==========================
3+
4+
.. code-block:: python
5+
6+
class CriticalExit(Thread):
7+
"""
8+
use to make program interrupt
9+
"""
10+
11+
def __init__(self, default_daemon: bool = True):
12+
"""
13+
default interrupt is keyboard F7 key
14+
:param default_daemon bool thread setDaemon
15+
"""
16+
17+
def set_critical_key(self, keycode: [int, str] = None):
18+
"""
19+
set interrupt key
20+
:param keycode interrupt key
21+
"""
22+
23+
def run(self):
24+
"""
25+
listener keycode _exit_check_key to interrupt
26+
"""
27+
28+
def init_critical_exit(self):
29+
"""
30+
should only use this to start critical exit
31+
may this function will add more
32+
"""
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
AutoControlGUI Executor Doc
2+
==========================
3+
4+
.. code-block:: python
5+
6+
def execute_action(action_list: list):
7+
"""
8+
use to execute all action on action list(action file or python list)
9+
:param action_list the list include action
10+
for loop the list and execute action
11+
"""
12+
13+
"""
14+
Executor example
15+
on program or action file
16+
use format like bottom
17+
[function_name, {param: value,...}]
18+
if no param use [function_name]
19+
"""
20+
from je_auto_control import execute_action
21+
from je_auto_control import test_record
22+
"windows"
23+
example_list = [
24+
["type_key", {"keycode": 65}],
25+
["mouse_left", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
26+
["position"],
27+
["press_mouse", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
28+
["release_mouse", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}]
29+
]
30+
"macos"
31+
example_list = [
32+
["type_key", {"keycode": 0x00}],
33+
["mouse_left", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
34+
["position"],
35+
["press_mouse", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
36+
["release_mouse", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
37+
["type_key", {"mouse_keycode": "dwadwawda", "dwadwad": 500, "wdawddwawad": 500}]
38+
]
39+
"linux"
40+
example_list = [
41+
["type_key", {"keycode": 38}],
42+
["mouse_left", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
43+
["position"],
44+
["press_mouse", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
45+
["release_mouse", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
46+
["type_key", {"mouse_keycode": "dwadwawda", "dwadwad": 500, "wdawddwawad": 500}]
47+
]
48+
execute_action(example_list)
49+
50+
def read_action_json(json_file_path: str):
51+
"""
52+
use to read action file
53+
:param json_file_path json file's path to read
54+
"""
55+
56+
def write_action_json(json_save_path: str, action_json: list):
57+
"""
58+
use to save action file
59+
:param json_save_path json save path
60+
:param action_json the json str include action to write
61+
"""
62+
63+
.. code-block:: python
64+
65+
def execute_files(execute_files_list: list):
66+
"""
67+
:param execute_files_list: list include execute files path
68+
:return: every execute detail as list
69+
"""
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
AutoControlGUI File Process Doc
2+
==========================
3+
4+
5+
.. code-block:: python
6+
7+
def get_dir_files_as_list(dir_path: str = getcwd(), default_search_file_extension: str = ".json"):
8+
"""
9+
get dir file when end with default_search_file_extension
10+
:param dir_path: which dir we want to walk and get file list
11+
:param default_search_file_extension: which extension we want to search
12+
:return: [] if nothing searched or [file1, file2.... files] file was searched
13+
"""
14+
return [
15+
abspath(join(dir_path, file)) for root, dirs, files in walk(dir_path)
16+
for file in files
17+
if file.endswith(default_search_file_extension.lower())
18+
]
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
AutoControlGUI Image Doc
2+
==========================
3+
4+
.. code-block:: python
5+
6+
def locate_all_image(image, detect_threshold: [float, int] = 1, draw_image: bool = False, **kwargs):
7+
"""
8+
use to locate all image that detected and then return detected images list
9+
:param image which image we want to find on screen (png or PIL ImageGrab.grab())
10+
:param detect_threshold detect precision 0.0 ~ 1.0; 1 is absolute equal (float or int)
11+
:param draw_image draw detect tag on return image (bool)
12+
"""
13+
14+
def locate_image_center(image, detect_threshold: [float, int] = 1, draw_image: bool = False, **kwargs):
15+
"""
16+
use to locate image and return image center position
17+
:param image which image we want to find on screen (png or PIL ImageGrab.grab())
18+
:param detect_threshold detect precision 0.0 ~ 1.0; 1 is absolute equal (float or int)
19+
:param draw_image draw detect tag on return image (bool)
20+
"""
21+
22+
def locate_and_click(image, mouse_keycode: [int, str], detect_threshold: [float, int] = 1, draw_image: bool = False, **kwargs):
23+
"""
24+
use to locate image and click image center position and the return image center position
25+
:param image which image we want to find on screen (png or PIL ImageGrab.grab())
26+
:param mouse_keycode which mouse keycode we want to click
27+
:param detect_threshold detect precision 0.0 ~ 1.0; 1 is absolute equal (float or int)
28+
:param draw_image draw detect tag on return image (bool)
29+
"""
30+
31+
def screenshot(file_path: str = None, region: list = None):
32+
"""
33+
use to get now screen image return image
34+
:param file_path save screenshot path (None is no save)
35+
:param region screenshot region (screenshot region on screen)
36+
"""
37+
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
AutoControlGUI Keyboard Doc
2+
==========================
3+
4+
5+
.. code-block:: python
6+
7+
def press_key(keycode: [int, str], is_shift: bool = False):
8+
"""
9+
use to press a key still press to use release key
10+
or use critical exit
11+
return keycode
12+
:param keycode which keycode we want to press
13+
:param is_shift press shift True or False
14+
"""
15+
16+
def release_key(keycode: [int, str], is_shift: bool = False):
17+
"""
18+
use to release pressed key return keycode
19+
:param keycode which keycode we want to release
20+
:param is_shift press shift True or False
21+
"""
22+
23+
def type_key(keycode: [int, str], is_shift: bool = False):
24+
"""
25+
press and release key return keycode
26+
:param keycode which keycode we want to type
27+
:param is_shift press shift True or False
28+
"""
29+
30+
def check_key_is_press(keycode: [int, str]):
31+
"""
32+
use to check key is press return True or False
33+
:param keycode check key is press or not
34+
"""
35+
36+
def write(write_string: str, is_shift: bool = False):
37+
"""
38+
use to press and release whole we get this function str
39+
return all press and release str
40+
:param write_string while string not on write_string+1 type_key(string)
41+
:param is_shift press shift True or False
42+
"""
43+
44+
def hotkey(key_code_list: list, is_shift: bool = False):
45+
"""
46+
use to press and release all key on key_code_list
47+
then reverse list press and release again
48+
return [press_str_list, release_str_list]
49+
:param key_code_list press and release all key on list and reverse
50+
:param is_shift press shift True or False
51+
"""
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
AutoControlGUI Mouse Doc
2+
==========================
3+
4+
5+
.. code-block:: python
6+
7+
def mouse_preprocess(mouse_keycode: [int, str], x: int, y: int):
8+
"""
9+
check mouse keycode is verified or not
10+
and then check current mouse position
11+
if x or y is None set x, y is current position
12+
:param mouse_keycode which mouse keycode we want to click
13+
:param x mouse click x position
14+
:param y mouse click y position
15+
"""
16+
17+
def position():
18+
"""
19+
get mouse current position
20+
return mouse_x, mouse_y
21+
"""
22+
23+
def set_position(x: int, y: int):
24+
"""
25+
:param x set mouse position x
26+
:param y set mouse position y
27+
return x, y
28+
"""
29+
30+
def press_mouse(mouse_keycode: [int, str], x: int = None, y: int = None):
31+
"""
32+
press mouse keycode on x, y
33+
return keycode, x, y
34+
:param mouse_keycode which mouse keycode we want to press
35+
:param x mouse click x position
36+
:param y mouse click y position
37+
"""
38+
39+
def release_mouse(mouse_keycode: [int, str], x: int = None, y: int = None):
40+
"""
41+
release mouse keycode on x, y
42+
return keycode, x, y
43+
:param mouse_keycode which mouse keycode we want to release
44+
:param x mouse click x position
45+
:param y mouse click y position
46+
"""
47+
48+
def click_mouse(mouse_keycode: [int, str], x: int = None, y: int = None):
49+
"""
50+
press and release mouse keycode on x, y
51+
return keycode, x, y
52+
:param mouse_keycode which mouse keycode we want to click
53+
:param x mouse click x position
54+
:param y mouse click y position
55+
"""
56+
57+
def scroll(scroll_value: int, x: int = None, y: int = None, scroll_direction: str = "scroll_down"):
58+
""""
59+
:param scroll_value scroll count
60+
:param x mouse click x position
61+
:param y mouse click y position
62+
:param scroll_direction which direction we want
63+
scroll_direction = scroll_up : direction up
64+
scroll_direction = scroll_down : direction down
65+
scroll_direction = scroll_left : direction left
66+
scroll_direction = scroll_right : direction right
67+
"""
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
AutoControlGUI Record Doc
2+
==========================
3+
4+
5+
.. code-block:: python
6+
7+
def record():
8+
"""
9+
start record keyboard and mouse event until stop_record
10+
"""
11+
12+
def stop_record():
13+
"""
14+
stop current record
15+
"""

0 commit comments

Comments
 (0)