sindresorhus/get-windows

Is it possible to get the path to the current *file* (not app)?

Open

#109 opened on Apr 27, 2021

View on GitHub
 (2 comments) (0 reactions) (0 assignees)JavaScript (194 forks)user submission
enhancementhelp wanted

Repository metrics

Stars
 (913 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

Thanks for this cool tool!

Right now, it seems like active-win returns the path to the app behind the currently active window. That's not surprising, as the ReadMe says as much. But is it possible to get the path to the file that is in the active window?

For example, if the current window is a microsoft word file titled "great-document" saved to my desktop, running console.log(await activeWindow()) returns:

{
  memoryUsage: ...,
  title: 'great-document',
  bounds: ...,
  owner: {
    name: 'Microsoft Word',
    processId: ...,
    path: '/Applications/Microsoft Word.app',
    bundleId: 'com.microsoft.Word'
  },
  id: ...,
  platform: 'macos'
}

The path that is listed here is the path to Microsoft Word, the app, itself.

I'm hoping to find the path to the file itself, which in this case would be: Users/NL33/desktop/great-document.doc

Is there a way to use active-win to do that? Is it possible in general?

Contributor guide