pywinrt / python-winsdk

Python package with bindings for Windows SDK
https://python-winsdk.readthedocs.io
MIT License
77 stars 8 forks source link

Access is Denied when trying to use GeoLocation #38

Closed psychoSherlock closed 1 year ago

psychoSherlock commented 1 year ago
import winsdk.windows.devices.geolocation as wdg
import asyncio

async def getCoords():
    locator = wdg.Geolocator()
    pos = await locator.get_geoposition_async()
    return [pos.coordinate.latitude, pos.coordinate.longitude]

def getLoc():
    return asyncio.run(getCoords())

getLoc()
PermissionError: [WinError -2147024891] Access is denied
dlech commented 1 year ago

I would check the Windows settings to make sure location services are enabled.

psychoSherlock commented 1 year ago

Damn you are fast man. 😂 Silly me. That was the error. I was trying everything.

psychoSherlock commented 1 year ago

Also, just another silly doubt. Why does my laptop sometimes show not so accurate location but sometime it does?

psychoSherlock commented 1 year ago

Just wanna make sure if its using the hardware or the IP address

dlech commented 1 year ago

I don't know much about how it works.

Maybe this is helpful: https://support.microsoft.com/en-us/windows/windows-location-service-and-privacy-3a8eee0a-5b0b-dc07-eede-2a5ca1c49088