Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 648179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:48:14+00:00 2026-05-13T21:48:14+00:00

I know the process id of an application in Mac OS X. How can

  • 0

I know the process id of an application in Mac OS X. How can I switch to it (using applescript, or python, or whatever)?

By “switch”, I mean, put in focus.

The usual solution is to use the applescript code tell application "Foo" activate, but here the name is not useful because I have many instances of the same application running. I am however able to get the process id of the application.

How can I switch to this application programmatically?

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T21:48:14+00:00Added an answer on May 13, 2026 at 9:48 pm

    If you don’t want to /can’t install any additional software, there is a built-in way of looking up process IDs and apps: ps.

    ps is a useful command line tool to find info on running processes. To find a particular app given the process number (which I’ve assigned to a variable myProcessId):

    do shell script "ps -p " & myProcessId
    

    this will return a result like this

      PID TTY           TIME CMD
    66766 ??         9:17.66 /Applications/Firefox.app/Contents/MacOS/firefox-bin -psn_0_3793822
    

    to restrict the result to just the relevant line, pipe it to grep like so

    do shell script "ps -p " & myProcessId & "|grep " & myProcessId
    

    By parsing the answer you can find the name of the app. This might be a little tricky because the result will show the actual command used for the app, not the app name (if you look at the example you’ll see it is possible to find it by looking for something.app in the result).

    Edit – sorry, I misunderstood the question.

    You can do it with system events (turns out to be much easier than faffing around with the shell anyway):

    tell application "System Events"
        set theprocs to every process whose unix id is myProcessId
        repeat with proc in theprocs
            set the frontmost of proc to true
        end repeat
    end tell
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can i get a process by know process name on mac os?
I know that in c# I can do: Process currentProcess = System.Diagnostics.Process.GetCurrentProcess(); currentProcess.Modules[0].BaseAddress currentProcess.Modules[0].EntryPointAddress
OK - I know I can run my java process like this : java
If I do Process.fork do x end how can I know what x returned
I can understand Appdomain concept, but small doubt is One Process -> many application
Does anyone know any good tutorial about using NAnt for native code build process
I am using eclipse. I am trying to kill a process in my application.
I would like to know the process and service providers who will enable me
assuming that I know the PID of a process and want to do a
The only pre-process directive that I know about in VBScript / Classic ASP is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.