Skip to content

Commit

Permalink
add doc and test
Browse files Browse the repository at this point in the history
add doc and test
  • Loading branch information
JE-Chen committed Nov 19, 2022
1 parent 11c60e7 commit 9a9dada
Show file tree
Hide file tree
Showing 26 changed files with 972 additions and 15 deletions.
52 changes: 39 additions & 13 deletions .idea/workspace.xml

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

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
@@ -0,0 +1,32 @@
AutoControlGUI Critical Exit Doc
==========================

.. code-block:: python
class CriticalExit(Thread):
"""
use to make program interrupt
"""
def __init__(self, default_daemon: bool = True):
"""
default interrupt is keyboard F7 key
:param default_daemon bool thread setDaemon
"""
def set_critical_key(self, keycode: [int, str] = None):
"""
set interrupt key
:param keycode interrupt key
"""
def run(self):
"""
listener keycode _exit_check_key to interrupt
"""
def init_critical_exit(self):
"""
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,69 @@
AutoControlGUI Executor Doc
==========================

.. code-block:: python
def execute_action(action_list: list):
"""
use to execute all action on action list(action file or python list)
:param action_list the list include action
for loop the list and execute action
"""
"""
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):
"""
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):
"""
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):
"""
: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,18 @@
AutoControlGUI File Process Doc
==========================


.. code-block:: python
def get_dir_files_as_list(dir_path: str = getcwd(), default_search_file_extension: str = ".json"):
"""
get dir file when end with default_search_file_extension
:param dir_path: which dir we want to walk and get file list
: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,37 @@
AutoControlGUI Image Doc
==========================

.. code-block:: python
def locate_all_image(image, detect_threshold: [float, int] = 1, draw_image: bool = False, **kwargs):
"""
use to locate all image that detected and then return detected images list
:param image which image we want to find on screen (png or PIL ImageGrab.grab())
: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
:param image which image we want to find on screen (png or PIL ImageGrab.grab())
: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)
"""
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
AutoControlGUI Keyboard Doc
==========================


.. code-block:: python
def press_key(keycode: [int, str], is_shift: bool = False):
"""
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
:param is_shift press shift True or False
"""
def release_key(keycode: [int, str], is_shift: bool = False):
"""
use to release pressed key return keycode
:param keycode which keycode we want to release
: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
: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):
"""
use to press and release whole we get this function str
return all press and release str
:param write_string while string not on write_string+1 type_key(string)
:param is_shift press shift True or False
"""
def hotkey(key_code_list: list, is_shift: bool = False):
"""
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]
:param key_code_list press and release all key on list and reverse
:param is_shift press shift True or False
"""
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
AutoControlGUI Mouse Doc
==========================


.. 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
if x or y is None set x, y is current position
:param mouse_keycode which mouse keycode we want to click
:param x mouse click x position
:param y mouse click y position
"""
def position():
"""
get mouse current position
return mouse_x, mouse_y
"""
def set_position(x: int, y: int):
"""
: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 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
"""
def release_mouse(mouse_keycode: [int, str], x: int = None, y: int = None):
"""
release mouse keycode on x, y
return 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
"""
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
:param mouse_keycode which mouse keycode we want to click
:param x mouse click x position
: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
:param x mouse click x position
:param y mouse click 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
"""
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
AutoControlGUI Record Doc
==========================


.. code-block:: python
def record():
"""
start record keyboard and mouse event until stop_record
"""
def stop_record():
"""
stop current record
"""
Loading

0 comments on commit 9a9dada

Please sign in to comment.