如何将 python 程序设置为 Windows 中的默认 Web 浏览器? [英] How do I set a python program as the default Web browser in Windows?

查看:61
本文介绍了如何将 python 程序设置为 Windows 中的默认 Web 浏览器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小的 python 程序,它接受一个 URL 并将其发送到相邻的机器,该机器有一个服务器,可以接收 URL 并在浏览器中打开它们.

I have a small python program that takes a URL and sends it to a neighbouring machine, which has a server that receives URLs and opens them in the browser.

我的下一步是将此 python 程序注册为本地 Windows 框中的默认浏览器,以便在我单击任何位置(聊天软件、电子邮件客户端、其他应用程序)的链接时获取 URL.

My next step is to register this python program as the default browser in the local Windows box so that it gets the URLs when I click on links anywhere (Chat software, email clients, other applications).

如何将自定义应用程序注册为 Windows 中的默认 Web 浏览器?

How does one register a custom application as the default Web browser in windows?

其他问题:对此的最低要求是什么?我可以将它恢复到以前的值吗?是否有一个 python 库?

Additional questions: What are the minimum requirements for this? Can I revert it back to the previous value? Is there a python library for that?

推荐答案

答案取决于 Windows 的版本.在过去,您必须修改注册表.在较新的版本中,您可以使用一两个接口更改 http 协议关联.然后,您只能通过不同的 API 提出关联,并让用户采取行动进行确认.在最新版本的 Windows 中,他们几乎不可能更改某些类型的默认值来保护用户免受竞争应用程序发起的默认值之战.

The answer depends on the version of Windows. In the olden days, you had to tinker in the registry. In newer versions, you could change the http protocol association with an interface or two. Then you could only propose an association through a different API and get the user to take action to confirm it. In the newest versions of Windows, they've made it virtually impossible to change certain kinds of defaults to protect the users from a war of defaults being waged by competing applications.

如果这是一次性的,我会通过当前版本的 Windows 中包含的默认程序控制面板小程序手动设置它.

If this is a one-off, I would just set it manually through the Default Programs control panel applet that's included in current versions of Windows.

如果您想以编程方式尝试,this 似乎是文档的一个很好的切入点.

If you want to attempt it programmatically, this seems like a good entry point into the documentation.

这篇关于如何将 python 程序设置为 Windows 中的默认 Web 浏览器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆