Created
February 14, 2022 18:52
-
-
Save Netzvamp/1c67116e80fbea59024f65da5f640359 to your computer and use it in GitHub Desktop.
Set your own Python script or executable as tel link handler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# manage windows tel links | |
import sys | |
import os | |
import logging | |
log = logging.getLogger(__name__) | |
def init(): | |
""" | |
Set our dialer as tel link handler. Currently only for windows. | |
""" | |
if sys.platform == "win32": | |
import winreg | |
if sys.argv[0][-3:] == ".py": # we are not running with pyinstaller | |
key_value = f"{sys.executable} {os.path.abspath(os.path.join(os.path.split(sys.argv[0])[0], 'dialer.py'))} %1" | |
else: | |
key_value = f"{os.path.join(os.path.split(sys.executable)[0], 'dialer.exe')} %1" | |
log.debug(f"Register for 'tel:' links: {key_value}") | |
key = winreg.CreateKey(winreg.HKEY_CURRENT_USER, "SOFTWARE\\Classes\\tel") | |
winreg.SetValue(key, "", winreg.REG_SZ, "URL:tel") | |
winreg.SetValueEx(key, "URL Protocol", 0, winreg.REG_SZ, "") | |
winreg.SetValue( | |
winreg.CreateKey(winreg.HKEY_CURRENT_USER, "SOFTWARE\\Classes\\CCAgent.tel\\Shell\\Open\\Command"), | |
"", winreg.REG_SZ, key_value) | |
key = winreg.CreateKey(winreg.HKEY_CURRENT_USER, "SOFTWARE\\CCAgent\\Capabilities") | |
winreg.SetValueEx(key, "ApplicationName", 0, winreg.REG_SZ, "CCAgent") | |
winreg.SetValueEx(key, "ApplicationDescription", 0, winreg.REG_SZ, "CCAgent Dialer") | |
key = winreg.CreateKey(winreg.HKEY_CURRENT_USER, "SOFTWARE\\CCAgent\\Capabilities\\URLAssociations") | |
winreg.SetValueEx(key, "tel", 0, winreg.REG_SZ, "CCAgent.tel") | |
winreg.SetValueEx( | |
winreg.CreateKey(winreg.HKEY_CURRENT_USER, "SOFTWARE\\RegisteredApplications"), | |
"CCAgent", 0, winreg.REG_SZ, "Software\\CCAgent\\Capabilities") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment