Skip to main content

Get front app pid (app.front_pid)

Declaration

pid = app.front_pid()

Returns

  • pid
    Integer. The pid of the foreground app, or 0 if no app is in the foreground.

Notes

  • Get the pid of the foreground app.
  • If you need the SpringBoard pid, use:
local desktop_pid = app.pid_for_bid('com.apple.springboard')
sys.alert("SpringBoard pid: "..desktop_pid)

Example

local pid = app.front_pid()
sys.alert("Foreground app pid: "..pid)

Note: uses non-chapter API sys.alert.