Skip to content

Commit a244ae4

Browse files
committed
Fix the keyboard intro
Fix the keyboard intro
1 parent c8c9f59 commit a244ae4

File tree

18 files changed

+54
-124
lines changed

18 files changed

+54
-124
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
Callback function documentation
1+
回調函數 文件
22
----
33

44
在 AutoControl 裡,Callback function 是由 Callback Executor 提供支援,
55
以下是簡易的使用 Callback Executor 的範例,
66

77
.. code-block:: python
8+
89
from je_auto_control import callback_executor
910
# trigger_function will first to execute, but return value need to wait everything done
1011
# so this test will first print("test") then print(size_function_return_value)
@@ -20,8 +21,6 @@ Callback function documentation
2021
* ( 注意!,如果 callback_executor event_dict 裡面包含的 name: function 需與 executor 一樣,不一樣則是 Bug)
2122
* (當然跟 executor 一樣可以藉由添加外部 function 來擴充,請看下面例子)
2223

23-
-----
24-
2524
在這個範例裡,我們使用 callback_executor 執行定義在 AutoControl 的 size function,
2625
然後執行完 size function 後,會去執行傳遞給 callback_function 的 function,
2726
可以由 callback_param_method 參數來決定要使用的傳遞方法,
@@ -31,25 +30,19 @@ Callback function documentation
3130
實際上 size -> print 順序沒錯,但此例會先看到 print 之後才是 print(size_function_return_value),
3231
因為 size function 只有回傳值本身沒有 print 的動作。
3332

34-
-----
35-
3633
如果我們想要在 callback_executor 裡面添加 function,可以使用如下:
3734
這段程式碼會把所有 time module 的 builtin, function, method, class
3835
載入到 callback executor,然後要使用被載入的 function 需要使用 package_function 名稱,
3936
例如 time.sleep 會變成 time_sleep
4037

41-
----
42-
4338
.. code-block:: python
39+
4440
from je_auto_control import package_manager
4541
package_manager.add_package_to_callback_executor("time")
4642
47-
----
48-
4943
如果你需要查看被更新的 event_dict 可以使用
5044

51-
----
52-
5345
.. code-block:: python
46+
5447
from je_auto_control import callback_executor
5548
print(callback_executor.event_dict)

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

+3-8
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
1-
CLI documentation
2-
----
3-
1+
命令列介面 文件
42
----
53

64
我們可以使用 CLI 模式去執行 keyword.json 檔案或執行包含 Keyword.json files 的資料夾,
75
以下這個範例是去執行指定路徑的關鍵字 json 檔
86

9-
----
10-
117
.. code-block::
8+
129
python je_auto_control --execute_file "C:\Users\JeffreyChen\Desktop\Code_Space\AutoControl\test\unit_test\argparse\test1.json"
1310
1411
15-
----
1612
1713
以下這個範例是去執行指定路徑資料夾下所有的 keyword json 檔
1814

19-
----
20-
2115
.. code-block::
16+
2217
python je_auto_control --execute_dir "C:\Users\JeffreyChen\Desktop\Code_Space\AutoControl\test\unit_test\argparse"

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

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,16 @@
1-
Critical Exit documentation
1+
緊急退出 文件
22
----
3-
4-
----
5-
63
* Critical Exit 是提供故障保護的機制。
74
* Critical Exit 預設是關閉的。
85
* 如果開啟,預設按鍵是 F7。
96
* 開啟的方法是 CriticalExit().init_critical_exit()
107

11-
----
12-
138
以下這個範例是讓滑鼠不受控制的移動並拋出例外,
149
當接收到例外,初始化 Critical Exit 並自動按下 F7,
1510
( 注意! 如果修改這個範例必須極度小心。 )
1611

17-
----
18-
1912
.. code-block:: python
13+
2014
import sys
2115
2216
from je_auto_control import AutoControlMouseException

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

+4-14
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
1-
Generate Report documentation
1+
報告產生 文件
22
----
33

44
Generate Report 可以生成以下格式的報告
55
* HTML
66
* JSON
77
* XML
8-
9-
----
10-
118
* Generate Report 主要用來記錄與確認有哪些步驟執行,執行是否成功,
129
* 如果要使用 Generate Report 需要先設定紀錄為 True,使用 test_record_instance.init_record = True
1310
* 下面的範例有搭配 keyword and executor 如果看不懂可以先去看看 executor
14-
1511
以下是產生 HTML 的範例。
1612

17-
----
18-
1913
.. code-block:: python
14+
2015
import sys
2116
2217
from je_auto_control import execute_action
@@ -61,13 +56,11 @@ Generate Report 可以生成以下格式的報告
6156
print("\n\n")
6257
execute_action(test_list)
6358
64-
----
6559
6660
以下是產生 JSON 的範例。
6761

68-
----
69-
7062
.. code-block:: python
63+
7164
import sys
7265
7366
from je_auto_control import execute_action
@@ -112,13 +105,10 @@ Generate Report 可以生成以下格式的報告
112105
print("\n\n")
113106
execute_action(test_list)
114107
115-
----
116-
117108
以下是產生 XML 的範例。
118109

119-
----
120-
121110
.. code-block:: python
111+
122112
import sys
123113
124114
from je_auto_control import execute_action

docs/source/Eng/doc/image/image_doc.rst

+5-14
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
1-
Image documentation
1+
圖片偵測 文件
22
----
33

44
* Image 提供了關於圖像辨識的功能。
55
* 定位一張圖片在螢幕中的位置。
66
* 定位多張圖片在螢幕中的位置。
77
* 定位圖片在螢幕中的位置並點擊。
88

9-
----
10-
119
以下範例是定位所有圖片
1210

13-
----
14-
1511
.. code-block:: python
12+
1613
import time
1714
1815
from je_auto_control import locate_all_image
@@ -26,13 +23,10 @@ Image documentation
2623
image_data = locate_all_image(screenshot(), detect_threshold=0.9, draw_image=False)
2724
print(image_data)
2825
29-
----
30-
31-
以下範例是定位並點擊'圖片
32-
33-
----
26+
以下範例是定位並點擊圖片
3427

3528
.. code-block:: python
29+
3630
import time
3731
3832
from je_auto_control import locate_and_click
@@ -45,13 +39,10 @@ Image documentation
4539
image_data = locate_and_click(screenshot(), "mouse_left", detect_threshold=0.9, draw_image=False)
4640
print(image_data)
4741
48-
----
49-
5042
以下範例是定位圖片
5143

52-
----
53-
5444
.. code-block:: python
45+
5546
import time
5647
5748
from je_auto_control import locate_image_center

docs/source/Eng/doc/info/info_doc.rst

Whitespace-only changes.

docs/source/Eng/doc/installation/installation_doc.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Installation documentation
1+
安裝 文件
22
----
33

44
.. code-block:: python
@@ -15,6 +15,7 @@ Installation documentation
1515
* ubuntu 20.0.4
1616

1717
| 如果想要在樹梅派使用
18+
1819
.. code-block:: python
1920
2021
sudo apt-get install python3

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

+7-22
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Keyboard documentation
1+
鍵盤 文件
22
----
33

44
* 主要用來模擬鍵盤的控制。
@@ -8,68 +8,53 @@ Keyboard documentation
88
* special_table 是特定的鍵盤按鍵 ( 注意! 不是每個平台都有 )
99
* keys_table 是所有可以使用的按鍵
1010

11-
----
12-
1311
.. code-block:: python
12+
1413
from je_auto_control import keys_table, get_special_table
1514
1615
print(keys_table)
1716
print(get_special_table())
1817
19-
----
2018
2119
以下範例是按著鍵盤的某個按鍵,並在一秒後釋放
2220

23-
----
24-
2521
.. code-block:: python
22+
2623
from time import sleep
2724
from je_auto_control import press_key, release_key
2825
2926
press_key("a")
3027
sleep(1)
3128
release_key("a")
3229
33-
----
34-
3530
以下範例是按下與釋放按鍵
3631

37-
----
38-
3932
.. code-block:: python
33+
4034
from je_auto_control import type_key
4135
4236
type_key("a")
4337
44-
----
45-
4638
以下範例是檢查鍵盤 a 鍵是否按著
4739

48-
----
49-
5040
.. code-block:: python
41+
5142
from je_auto_control import check_key_is_press
5243
5344
check_key_is_press("a")
5445
55-
----
56-
5746
以下範例是按下與放開一串按鍵
5847

59-
----
60-
6148
.. code-block:: python
49+
6250
from je_auto_control import write
6351
6452
write("abcdefg")
6553
66-
----
67-
6854
以下範例是按下按鍵並相反的釋放
6955

70-
----
71-
7256
.. code-block:: python
57+
7358
import sys
7459
7560
from je_auto_control import hotkey

docs/source/Eng/doc/keyword/keyword_doc.rst

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
Keyword and Executor documentation
1+
鍵盤與執行者 文件
22
----
33

44
* Keyword 是一個 JSON 檔案裏面包含許多自定義的關鍵字與參數。
55
* Keyword 會與 Executor 搭配使用。
66
* Keyword 的格式是以下範例,且在 JSON 檔案裡面使用一樣格式。
77

88
.. code-block:: python
9+
910
[
1011
["function_name_in_event_dict": {"param_name": param_value}],
1112
["function_name_in_event_dict": {"param_name": param_value}],
@@ -14,45 +15,36 @@ Keyword and Executor documentation
1415
# If you are using position param
1516
["function_name_in_event_dict": {param_value1, param_value2....}]
1617
]
17-
----
1818
1919
如果我們想要在 executor 裡面添加 function,可以使用如下:
2020
這段程式碼會把所有 time module 的 builtin, function, method, class
2121
載入到 executor,然後要使用被載入的 function 需要使用 package_function 名稱,
2222
例如 time.sleep 會變成 time_sleep
2323

24-
----
25-
2624
.. code-block:: python
25+
2726
from je_auto_control import package_manager
2827
package_manager.add_package_to_executor("time")
2928
30-
----
3129
32-
如果你需要查看被更新的 event_dict 可以使用
3330
34-
----
31+
如果你需要查看被更新的 event_dict 可以使用
3532

3633
.. code-block:: python
34+
3735
from je_auto_control import executor
3836
print(executor.event_dict)
3937
40-
----
41-
4238
如果我們想要執行 JSON 檔案
4339

44-
----
45-
4640
.. code-block:: python
41+
4742
from je_auto_control import execute_action, read_action_json
4843
execute_action(read_action_json(file_path))
4944
50-
----
51-
5245
如果我們想要執行資料夾裡所有 JSON 檔案
5346

54-
----
55-
5647
.. code-block:: python
48+
5749
from je_auto_control import execute_files, get_dir_files_as_list
5850
execute_files(get_dir_files_as_list(dir_path))

0 commit comments

Comments
 (0)