取得前台應用的行程號 (app.front_pid)
聲明
行程號 = app.front_pid()
回傳值
- 行程號
整數型,返回前台應用的行程號,前台沒有應用返回 0
說明
取得前台應用的行程號
前台沒有應用時返回 0,而不是返回 SpringBoard(桌面)的行程號
如需取得 SpringBoard 的行程號,請使用
local desktop_pid = app.pid_for_bid('com.apple.springboard')
sys.alert("桌面服务的进程号是:"..desktop_pid)
範例
local pid = app.front_pid()
sys.alert("前台应用的进程号是:"..pid)
注:上述代碼中使用了非本章函式 sys.alert