跳到主要内容

获取前台应用的进程号 (app.front_pid)

声明

进程号 = app.front_pid()

返回值

  • 进程号
    整数型,返回前台应用的进程号,前台没有应用返回 0

说明

获取前台应用的进程号
前台没有应用返回 0 而不是桌面服务的进程号
要获取桌面进程 pid 请用

local desktop_pid = app.pid_for_bid('com.apple.springboard')
sys.alert("桌面服务的进程号是:"..desktop_pid)

示例

local pid = app.front_pid()
sys.alert("前台应用的进程号是:"..pid)

:上述代码中使用了非本章函数 sys.alert