Methods
ensureBins(optopt) → {Promise}
- Description:
取得本套件之外部執行檔(AutoHotkey64.exe、z*.ahk腳本、screenCapture_*.exe): 首次使用時下載(或自鏡像取得)並以bin/manifest.json之SHA-256與大小校驗, 之後自快取取得(亦校驗)
規格: 外部執行檔之存放下載校驗與離線(制式規格)§6; 實作為wsemi之fsEnsureBins, 本套件不另寫下載、快取、鏡像、校驗 環境變數: W_BIN_CACHE(共用快取資料夾)、W_BIN_MIRROR(鏡像, 本地資料夾或http(s)網址)、W_BIN_OFFLINE(1為離線), 見README〈外部執行檔〉
- Source:
Example
import ensureBins from 'w-mousekey/src/ensureBins.mjs'
let bins = await ensureBins({ names: ['AutoHotkey64.exe', 'zclick.ahk'] })
console.log(bins['AutoHotkey64.exe'])
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
opt |
Object |
<optional> |
{}
|
輸入設定物件, 交wsemi之fsEnsureBins(names、cacheDir、mirror、offline、onProgress等), pkgRoot固定為本套件根 |
Returns:
回傳Promise, resolve回傳{ [檔名]: 絕對路徑 }, reject回傳帶code之Error(E_OFFLINE_MISSING等)
- Type
- Promise
init(opt)
- Source:
Parameters:
| Name | Type | Description | ||||||
|---|---|---|---|---|---|---|---|---|
opt |
Object |
Properties
|
init(opt)
- Source:
Parameters:
| Name | Type | Description | ||||||
|---|---|---|---|---|---|---|---|---|
opt |
Object |
Properties
|
(async) runScp(inputFile, optopt) → {Promise}
- Description:
讀取腳本檔並依序執行滑鼠點擊步驟
腳本檔為JSON5,內容為單一腳本物件或腳本物件陣列,腳本物件含repeat(重複次數,整數,負數為無限重複,預設1)、delay(每次重複完成後等待毫秒數,非負整數,預設0)與steps(步驟陣列),步驟含x、y(螢幕座標,須為整數,否則拋錯)與delay(點擊後等待毫秒數,整數,預設0)
- Source:
Parameters:
| Name | Type | Attributes | Default | Description | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
inputFile |
String | 輸入腳本檔路徑 |
||||||||||||
opt |
Object |
<optional> |
{}
|
輸入設定物件,預設{} Properties
|
Returns:
回傳Promise,resolve代表執行完畢(repeat為負數時永不resolve)
- Type
- Promise
(async) waitPics(names, optopt) → {Promise}
- Description:
輪詢螢幕直到辨識到指定圖片(withClick時一併點擊),多張圖時任一張辨識成功即結束
每輪依序以ckPic辨識names內各圖,任一成功即結束並回傳true,皆失敗則等待timeDelay後進入下一輪,嘗試完numMax輪仍皆失敗才回傳false;其餘opt同ckPic(fdTar、fdTmp、x、y、width、height、threshold、modeCompare、withClick、withDrag、dx、dy等),辨識所需之圖檔或資料夾不存在時ckPic拋錯,錯誤原樣向外拋出
- Source:
Parameters:
| Name | Type | Attributes | Default | Description | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
names |
String | Array | 輸入圖檔名稱(不含副檔名,檔案為{fdTar}/{name}.png)字串或字串陣列 |
||||||||||||||||||||||
opt |
Object |
<optional> |
{}
|
輸入設定物件,預設{} Properties
|
Returns:
回傳Promise,resolve回傳布林,true代表有一張圖辨識成功,false代表嘗試完全部輪數皆失敗
- Type
- Promise