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

I am not getting URL from activeWin #99

Closed
saivikas-500 opened this issue Feb 5, 2021 · 21 comments
Closed

I am not getting URL from activeWin #99

saivikas-500 opened this issue Feb 5, 2021 · 21 comments

Comments

@saivikas-500
Copy link

I am not getting URL from activeWin

@sindresorhus
Copy link
Owner

You haven't provided any actionable info.

@saivikas-500
Copy link
Author

saivikas-500 commented Feb 8, 2021

image
pls, find the above screenshot. I have checked in ubuntu OS at chrome browser. I am getting the title but not the URL. winData.URL is not getting.

@alive2tinker
Copy link

alive2tinker commented Feb 21, 2021

Hi there,
I'm also facing the same issue. however, it turns out to be limited to macOS big Sur since i tested it on macOS catalina and it worked fine

@alive2tinker
Copy link

here is an example of when I log window object

{
  owner: {
    path: '/Applications/Google Chrome.app',
    bundleId: 'com.google.Chrome',
    processId: 70077,
    name: 'Google Chrome'
  },
  title: 'GitHub',
  bounds: { y: 41, width: 1609, height: 956, x: 126 },
  memoryUsage: 1232,
  id: 8499,
  platform: 'macos'
}

@azu
Copy link

azu commented Apr 4, 2021

I have a similar problem with at electron app.

The app gets activeWin, but url property is missing when open the application as .app.
(open ./out/active-win-url-bug-darwin-x64/active-win-url-bug.app)
The app can gets url property when execute the application binary from CLI.
(./out/active-win-url-bug-darwin-x64/active-win-url-bug.app/Contents/MacOS/active-win-url-bug)

The app can get other properties in both cases.

I've created reproduce sample app.

image

Applescript behavior may be something different in each case.
https://github.com/sindresorhus/active-win/blob/a5112a5b31a9e69f0c56dbd408c0fb6de020eb5b/Sources/active-win/main.swift#L3-L12

@tkainrad
Copy link
Contributor

I have the exact same problem as @azu . Running the app from the command line mitigates the issue. Would be very interested in a fix or workaround.

@tkainrad
Copy link
Contributor

I have finally found the cause of this problem @azu

To be able to ask the user for browser automation permissions, your application needs the com.apple.security.automation.apple-events entitlement. In addition the NSAppleEventsUsageDescription key is required.

To be able to set the entitlement, the app has to be signed.
This was the final push needed for me to create an Apple Developer account and properly sign and notarize my app which can now show not only the keyboard shortcuts of the current application, but also for the currently active browser page :)

@ganeshpartheeban
Copy link

ganeshpartheeban commented Jun 29, 2021

@tkainrad Do you know how/where to setup the entitlement & the key that you have mentioned above ?

I am working on an electron-react project. I have my app code-signed with a Mac Dev Account certificate.
URL is getting fetched perfectly when run in dev mode. But URL returns undefined in prod mode.

Could you please help me with this ?

@tkainrad
Copy link
Contributor

Actually took me a while to figure it out. Hard to find any documentation on it. I had to look through open-source Electron apps to see how others do it. E.g. Sylk or Franz.

I use Electron Builder. It offers corresponding configuration options to be set in package.json. This is how it looks like for me:

    "mac": {
      "hardenedRuntime": true,
      "gatekeeperAssess": false,
      "entitlements": "build/entitlements.mac.plist",
      "entitlementsInherit": "build/entitlements.mac.plist",
      "extendInfo": {
        "NSAppleEventsUsageDescription": "Please allow access to script browser applications to detect the current URL when triggering instant lookup."
      }
    },

This is my build/entitlements.mac.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>com.apple.security.cs.allow-unsigned-executable-memory</key>
    <true/>
    <key>com.apple.security.automation.apple-events</key>
    <true/>
  </dict>
</plist>

I wish you success!

@tkainrad
Copy link
Contributor

I think this issue and #114 can probably be closed. A note in the Readme about the requirements for getting the URL could be nice.

@ganeshpartheeban
Copy link

This works perfectly. Thanks for your help @tkainrad

@yusuf-zafar
Copy link

has anyone got the url property? i dont seem to get it in the terminal. i have a windows OS and im working on nodejs.

@shoaib30
Copy link

shoaib30 commented Jan 11, 2023

has anyone got the url property? i dont seem to get it in the terminal. i have a windows OS and im working on nodejs.

@yusuf-zafar as per the readme, the url property is available only on macOS and not Windows and Linux.

url (string?) - URL of the active browser tab if the active window (macOS only)

@yusuf-zafar
Copy link

@shoaib30 thanks for replying. I figured out a way to fetch URL by making some changes in the npm module. The problem is that it highlights the URL when it reads it from the browser, I'm working on a desktop user-activity-tracking app. I need to make it so that it happens without getting the user's attention.

@SarathKmrM
Copy link

Hello
Is there a method to obtain browser URL in Windows and Linux operating systems?
hi @yusuf-zafar does your fix work for windows and linux ?
Thanks

@shiv2-3
Copy link

shiv2-3 commented Jan 15, 2024

active-win url only get on production base on my mac laptop other laptop is not worKing how to resolve this issue

@AadvikVashist
Copy link

@shoaib30 thanks for replying. I figured out a way to fetch URL by making some changes in the npm module. The problem is that it highlights the URL when it reads it from the browser, I'm working on a desktop user-activity-tracking app. I need to make it so that it happens without getting the user's attention.

Would you be willing to share the changes you made for windows?

@shiv2-3
Copy link

shiv2-3 commented Feb 25, 2024

This problem is resolved but windows platform issue not getting url how is it possible please help me

@shiv2-3
Copy link

shiv2-3 commented Feb 25, 2024

has anyone got the url property? i dont seem to get it in the terminal. i have a windows OS and im working on nodejs.

@yusuf-zafar as per the readme, the url property is available only on macOS and not Windows and Linux.

url (string?) - URL of the active browser tab if the active window (macOS only)

But not any solutions for windows platform

@shiv2-3
Copy link

shiv2-3 commented Apr 4, 2024

get active window url solution for linux

@SoftsSolutionPHP
Copy link

how to get the url in window operating system using this active-win...

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

No branches or pull requests