Skip to content

Commit 4061509

Browse files
committed
Refactor
1 parent a244ae4 commit 4061509

File tree

59 files changed

+384
-597
lines changed

Some content is hidden

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

59 files changed

+384
-597
lines changed

docs/source/Eng/doc/callback_function/callback_function_doc.rst

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
回調函數 文件
1+
Callback Function
22
----
33

4-
AutoControl 裡,Callback function 是由 Callback Executor 提供支援,
5-
以下是簡易的使用 Callback Executor 的範例,
4+
In AutoControl, callback functions are supported by the Callback Executor.
5+
Below is a simple example of using the Callback Executor:
66

77
.. code-block:: python
88
@@ -18,29 +18,35 @@
1818
)
1919
)
2020
21-
* ( 注意!,如果 callback_executor event_dict 裡面包含的 name: function 需與 executor 一樣,不一樣則是 Bug)
22-
* (當然跟 executor 一樣可以藉由添加外部 function 來擴充,請看下面例子)
23-
24-
在這個範例裡,我們使用 callback_executor 執行定義在 AutoControl 的 size function,
25-
然後執行完 size function 後,會去執行傳遞給 callback_function 的 function,
26-
可以由 callback_param_method 參數來決定要使用的傳遞方法,
27-
如果是 "args" 請傳入 {"any_name_but_not_duplicate": value, ...} 這裡 ... 代表可以複數傳入,
28-
如果是 "kwargs" 請傳入 {"actually_param_name": value, ...} 這裡 ... 代表可以複數傳入,
29-
然後如果要使用回傳值的話,由於回傳值會在所有 function 執行完後才回傳,
30-
實際上 size -> print 順序沒錯,但此例會先看到 print 之後才是 print(size_function_return_value),
31-
因為 size function 只有回傳值本身沒有 print 的動作。
32-
33-
如果我們想要在 callback_executor 裡面添加 function,可以使用如下:
34-
這段程式碼會把所有 time module 的 builtin, function, method, class
35-
載入到 callback executor,然後要使用被載入的 function 需要使用 package_function 名稱,
36-
例如 time.sleep 會變成 time_sleep
21+
* Note that if the "name: function" pair in the callback_executor event_dict is different from the executor, it is a bug.
22+
* Of course, like the executor, it can be expanded by adding external functions. Please see the example below.
23+
24+
In this example, we use callback_executor to execute the "size" function defined in AutoControl.
25+
After executing the "size" function, the function passed to callback_function will be executed.
26+
The delivery method can be determined by the callback_param_method parameter.
27+
If it is "args", please pass in {"value1", "value2", ...}.
28+
Here, the ellipsis (...) represents multiple inputs.
29+
If it is "kwargs", please pass in {"actually_param_name": value, ...}.
30+
Here, the ellipsis (...) again represents multiple inputs.
31+
If you want to use the return value,
32+
since the return value will only be returned after all functions are executed,
33+
you will actually see the "print" statement
34+
before the "print(size_function_return_value)" statement in this example,
35+
even though the order of size -> print is correct.
36+
This is because the "size" function only returns the value itself without printing it.
37+
38+
This code will load all built-in functions, methods, and classes of the time module into the callback executor.
39+
To use the loaded functions, we need to use the package_function name,
40+
for example, time.sleep will become time_sleep.
41+
42+
If we want to add functions in the callback_executor, we can use the following code:
3743

3844
.. code-block:: python
3945
4046
from je_auto_control import package_manager
4147
package_manager.add_package_to_callback_executor("time")
4248
43-
如果你需要查看被更新的 event_dict 可以使用
49+
If you need to check the updated event_dict, you can use:
4450

4551
.. code-block:: python
4652

docs/source/Eng/doc/critical_exit/critical_exit_doc.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from je_auto_control import AutoControlMouseException
1717
from je_auto_control import CriticalExit
1818
from je_auto_control import press_key
19-
from je_auto_control import set_position
19+
from je_auto_control import set_mouse_position
2020
from je_auto_control import size
2121
2222
# print your screen width and height
@@ -30,8 +30,8 @@
3030
3131
sleep(3)
3232
while True:
33-
set_position(200, 400)
34-
set_position(400, 600)
33+
set_mouse_position(200, 400)
34+
set_mouse_position(400, 600)
3535
raise AutoControlMouseException
3636
except Exception as error:
3737
print(repr(error), file=sys.stderr)

docs/source/Eng/doc/generate_report/generate_report_doc.rst

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,35 +22,35 @@ Generate Report 可以生成以下格式的報告
2222
if sys.platform in ["win32", "cygwin", "msys"]:
2323
test_list = [
2424
["set_record_enable", {"set_enable": True}],
25-
["type_key", {"keycode": 65}],
25+
["type_keyboard", {"keycode": 65}],
2626
["mouse_left", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
27-
["position"],
27+
["get_mouse_position"],
2828
["press_mouse", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
2929
["release_mouse", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
30-
["type_key", {"mouse_keycode": "dwadwawda", "dwadwad": 500, "wdawddwawad": 500}],
30+
["type_keyboard", {"mouse_keycode": "dwadwawda", "dwadwad": 500, "wdawddwawad": 500}],
3131
["generate_html_report"],
3232
]
3333
3434
elif sys.platform in ["linux", "linux2"]:
3535
test_list = [
3636
["set_record_enable", {"set_enable": True}],
37-
["type_key", {"keycode": 38}],
37+
["type_keyboard", {"keycode": 38}],
3838
["mouse_left", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
39-
["position"],
39+
["get_mouse_position"],
4040
["press_mouse", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
4141
["release_mouse", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
42-
["type_key", {"mouse_keycode": "dwadwawda", "dwadwad": 500, "wdawddwawad": 500}],
42+
["type_keyboard", {"mouse_keycode": "dwadwawda", "dwadwad": 500, "wdawddwawad": 500}],
4343
["generate_html_report"],
4444
]
4545
elif sys.platform in ["darwin"]:
4646
test_list = [
4747
["set_record_enable", {"set_enable": True}],
48-
["type_key", {"keycode": 0x00}],
48+
["type_keyboard", {"keycode": 0x00}],
4949
["mouse_left", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
50-
["position"],
50+
["get_mouse_position"],
5151
["press_mouse", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
5252
["release_mouse", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
53-
["type_key", {"mouse_keycode": "dwadwawda", "dwadwad": 500, "wdawddwawad": 500}],
53+
["type_keyboard", {"mouse_keycode": "dwadwawda", "dwadwad": 500, "wdawddwawad": 500}],
5454
["generate_html_report"],
5555
]
5656
print("\n\n")
@@ -71,35 +71,35 @@ Generate Report 可以生成以下格式的報告
7171
if sys.platform in ["win32", "cygwin", "msys"]:
7272
test_list = [
7373
["set_record_enable", {"set_enable": True}],
74-
["type_key", {"keycode": 65}],
74+
["type_keyboard", {"keycode": 65}],
7575
["mouse_left", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
76-
["position"],
76+
["get_mouse_position"],
7777
["press_mouse", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
7878
["release_mouse", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
79-
["type_key", {"mouse_keycode": "dwadwawda", "dwadwad": 500, "wdawddwawad": 500}],
79+
["type_keyboard", {"mouse_keycode": "dwadwawda", "dwadwad": 500, "wdawddwawad": 500}],
8080
["generate_json_report"],
8181
]
8282
8383
elif sys.platform in ["linux", "linux2"]:
8484
test_list = [
8585
["set_record_enable", {"set_enable": True}],
86-
["type_key", {"keycode": 38}],
86+
["type_keyboard", {"keycode": 38}],
8787
["mouse_left", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
88-
["position"],
88+
["get_mouse_position"],
8989
["press_mouse", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
9090
["release_mouse", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
91-
["type_key", {"mouse_keycode": "dwadwawda", "dwadwad": 500, "wdawddwawad": 500}],
91+
["type_keyboard", {"mouse_keycode": "dwadwawda", "dwadwad": 500, "wdawddwawad": 500}],
9292
["generate_json_report"],
9393
]
9494
elif sys.platform in ["darwin"]:
9595
test_list = [
9696
["set_record_enable", {"set_enable": True}],
97-
["type_key", {"keycode": 0x00}],
97+
["type_keyboard", {"keycode": 0x00}],
9898
["mouse_left", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
99-
["position"],
99+
["get_mouse_position"],
100100
["press_mouse", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
101101
["release_mouse", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
102-
["type_key", {"mouse_keycode": "dwadwawda", "dwadwad": 500, "wdawddwawad": 500}],
102+
["type_keyboard", {"mouse_keycode": "dwadwawda", "dwadwad": 500, "wdawddwawad": 500}],
103103
["generate_json_report"],
104104
]
105105
print("\n\n")
@@ -119,35 +119,35 @@ Generate Report 可以生成以下格式的報告
119119
if sys.platform in ["win32", "cygwin", "msys"]:
120120
test_list = [
121121
["set_record_enable", {"set_enable": True}],
122-
["type_key", {"keycode": 65}],
122+
["type_keyboard", {"keycode": 65}],
123123
["mouse_left", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
124-
["position"],
124+
["get_mouse_position"],
125125
["press_mouse", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
126126
["release_mouse", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
127-
["type_key", {"mouse_keycode": "dwadwawda", "dwadwad": 500, "wdawddwawad": 500}],
127+
["type_keyboard", {"mouse_keycode": "dwadwawda", "dwadwad": 500, "wdawddwawad": 500}],
128128
["generate_xml_report"]
129129
]
130130
131131
elif sys.platform in ["linux", "linux2"]:
132132
test_list = [
133133
["set_record_enable", {"set_enable": True}],
134-
["type_key", {"keycode": 38}],
134+
["type_keyboard", {"keycode": 38}],
135135
["mouse_left", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
136-
["position"],
136+
["get_mouse_position"],
137137
["press_mouse", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
138138
["release_mouse", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
139-
["type_key", {"mouse_keycode": "dwadwawda", "dwadwad": 500, "wdawddwawad": 500}],
139+
["type_keyboard", {"mouse_keycode": "dwadwawda", "dwadwad": 500, "wdawddwawad": 500}],
140140
["generate_xml_report"]
141141
]
142142
elif sys.platform in ["darwin"]:
143143
test_list = [
144144
["set_record_enable", {"set_enable": True}],
145-
["type_key", {"keycode": 0x00}],
145+
["type_keyboard", {"keycode": 0x00}],
146146
["mouse_left", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
147-
["position"],
147+
["get_mouse_position"],
148148
["press_mouse", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
149149
["release_mouse", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}],
150-
["type_key", {"mouse_keycode": "dwadwawda", "dwadwad": 500, "wdawddwawad": 500}],
150+
["type_keyboard", {"mouse_keycode": "dwadwawda", "dwadwad": 500, "wdawddwawad": 500}],
151151
["generate_xml_report"]
152152
]
153153
print("\n\n")

docs/source/Eng/doc/keyboard/keyboard_doc.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131

3232
.. code-block:: python
3333
34-
from je_auto_control import type_key
34+
from je_auto_control import type_keyboard
3535
36-
type_key("a")
36+
type_keyboard("a")
3737
3838
以下範例是檢查鍵盤 a 鍵是否按著
3939

docs/source/Eng/doc/mouse/mouse_doc.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@
3636

3737
.. code-block:: python
3838
39-
from je_auto_control import position, set_position
39+
from je_auto_control import get_mouse_position, set_mouse_position
4040
41-
print(position)
42-
set_position(100, 100)
41+
print(get_mouse_position())
42+
set_mouse_position(100, 100)
4343
4444
以下範例是3秒後滑鼠會往上 scroll
4545

docs/source/Eng/doc/record/record_doc.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@
1313
from je_auto_control import execute_action
1414
from je_auto_control import record
1515
from je_auto_control import stop_record
16-
from je_auto_control import type_key
16+
from je_auto_control import type_keyboard
1717
1818
# this program will type test two time
1919
# one time is type key one time is test_record
2020
2121
record()
2222
sleep(1)
23-
print(type_key("t"))
24-
print(type_key("e"))
25-
print(type_key("s"))
26-
print(type_key("t"))
23+
print(type_keyboard("t"))
24+
print(type_keyboard("e"))
25+
print(type_keyboard("s"))
26+
print(type_keyboard("t"))
2727
sleep(2)
2828
record_result = stop_record()
2929
print(record_result)

docs/source/Zh/doc/callback_function/callback_function_doc.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
回調函數 文件
1+
回調函數
22
----
33

44
在 AutoControl 裡,Callback function 是由 Callback Executor 提供支援,
@@ -24,7 +24,7 @@
2424
在這個範例裡,我們使用 callback_executor 執行定義在 AutoControl 的 size function,
2525
然後執行完 size function 後,會去執行傳遞給 callback_function 的 function,
2626
可以由 callback_param_method 參數來決定要使用的傳遞方法,
27-
如果是 "args" 請傳入 {"any_name_but_not_duplicate": value, ...} 這裡 ... 代表可以複數傳入,
27+
如果是 "args" 請傳入 {"value1", "value2", ...} 這裡 ... 代表可以複數傳入,
2828
如果是 "kwargs" 請傳入 {"actually_param_name": value, ...} 這裡 ... 代表可以複數傳入,
2929
然後如果要使用回傳值的話,由於回傳值會在所有 function 執行完後才回傳,
3030
實際上 size -> print 順序沒錯,但此例會先看到 print 之後才是 print(size_function_return_value),
@@ -35,6 +35,8 @@
3535
載入到 callback executor,然後要使用被載入的 function 需要使用 package_function 名稱,
3636
例如 time.sleep 會變成 time_sleep
3737

38+
這段程式碼會把 time 所有的 function 加入 executor(直譯器裡)。
39+
3840
.. code-block:: python
3941
4042
from je_auto_control import package_manager

docs/source/Zh/doc/cli/cli_doc.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
命令列介面 文件
1+
命令列介面
22
----
33

44
我們可以使用 CLI 模式去執行 keyword.json 檔案或執行包含 Keyword.json files 的資料夾,

docs/source/Zh/doc/critical_exit/critical_exit_doc.rst

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
緊急退出 文件
1+
緊急退出
22
----
3+
34
* Critical Exit 是提供故障保護的機制。
45
* Critical Exit 預設是關閉的。
56
* 如果開啟,預設按鍵是 F7。
6-
* 開啟的方法是 CriticalExit().init_critical_exit()
7+
* 開啟的方法是 CriticalExit().init_critical_exit() (開啟後會額外消耗系統資源)
78

89
以下這個範例是讓滑鼠不受控制的移動並拋出例外,
910
當接收到例外,初始化 Critical Exit 並自動按下 F7,
1011
( 注意! 如果修改這個範例必須極度小心。 )
12+
(你可能會失去對你電腦的控制,例如滑鼠不受控制)
1113

1214
.. code-block:: python
1315
@@ -27,11 +29,11 @@
2729
2830
try:
2931
from time import sleep
30-
32+
# Or no sleep
3133
sleep(3)
3234
while True:
33-
set_position(200, 400)
34-
set_position(400, 600)
35+
set_mouse_position(200, 400)
36+
set_mouse_position(400, 600)
3537
raise AutoControlMouseException
3638
except Exception as error:
3739
print(repr(error), file=sys.stderr)

0 commit comments

Comments
 (0)