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

  • Home
  • SEARCH
  • 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 5937289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:31:06+00:00 2026-05-22T15:31:06+00:00

Question Summary: how can I get the path to the currently active application under

  • 0

Question Summary:

  1. how can I get the path to the currently active application under OS X? (ie the application that owns the current key window)

  2. from that, I need to determine the normally associated .icns file for that application (ie the image that finder shows when you look at that application in the “Applications” folder, and in the application list that appears when you press command(apple) tab key)

Detailed Question description:

I am developing an OS X utility toolbar (floating window) that needs to display the name and icon image for the current application (eg the application that owns the window that is currently “key”.

  1. I need some way of programmatically determining “the path to .app folder” of the application that is currently main & key. This could either by via a notification callback, or something i can poll on a timer and trigger my own callbacks.

  2. I can see that manually finding .icns files inside the XXX.app/Resources folder is relatively easy, however the problems is there are sometimes more than 1 .icns file in that folder – and I can see no easy way to determine from the filename alone which is the correct icon normally associated with the application – whilst many applications use the same same name as the application (with an icns extension),some don’t.

safari for example has a completely unrelated name “compass.icns”. there must be a file somewhere that tells finder what file to use – or an api call to do this, anyone have any ideas? NSApplication has the applicationIconImage method, which obviously returns the icon for MY application – that’s not what I want – as far as I know there is no way of instantiating NSApplication for another application, and it would make no real sense to do this as most methods/properties are things that are private to that application.

for what it’s worth, I am porting a windows utility to OS X – if I were doing this under windows, I would use GetWindowProcessID(GetForegroundWindow)), and use that to determine the path to the application, and extract the icon from that using LoadIcon

  • 1 1 Answer
  • 0 Views
  • 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-22T15:31:07+00:00Added an answer on May 22, 2026 at 3:31 pm

    All these methods reside in NSWorkspace class. You can get the active application as well as its icon image (without icns file). Check the documentation for aforementioned class and it all should be clear to you:

    NSDictionary *activeAppDict = [[NSWorkspace sharedWorkspace] activeApplication];
    NSString *activeApplicationPath = [activeAppDict valueForKey:@"NSApplicationPath"];
    NSImage *activeAppImage = [[NSWorkspace sharedWorkspace] iconForFile:activeApplicationPath];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Some text before the code so that the question summary isn't mangled. class Tree
Question Can I build a image database/library that has an e-commerce style checkout system
Question says it all, really. My application is a time tracker. It's currently written
Question Using XSLT 1.0, given a string with arbitrary characters how can I get
I need to solve the following question which i can't get to work by
Ok so part two of I have no will power experiment is: Summary Question
Is there any way I can get VS2008 to provide further detail on how
I asked this question to get to know how to increase the runtime call
EDIT: If you can't be bothered to read this mammoth question, I've put a
this is actually a followup from a previous question but it contains different information

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.