Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
NL33 opened this issue Apr 27, 2021 · 2 comments
Open

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

NL33 opened this issue Apr 27, 2021 · 2 comments

Comments

@NL33
Copy link

NL33 commented Apr 27, 2021

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?

@sindresorhus
Copy link
Owner

sindresorhus commented Apr 27, 2021

It is possible to get it on macOS using AppleScript. We could support it here if anyone does a good pull request. For Windows and Linux, I have no idea.

The property should be called filePath and should be top-level, not in owner.

https://superuser.com/questions/295963/get-path-of-open-file-in-any-application-on-mac-os-x

@NL33
Copy link
Author

NL33 commented Apr 27, 2021

Ok. Thanks for the info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants