简体   繁体   English

PyQt 应用程序在 NSIS 安装程序后激活 Windows Focus Assist

[英]PyQt App activates Windows Focus Assist after NSIS installer

I wrote an app that reminds you to look away from the monitor every 20 minutes.我写了一个应用程序,每 20 分钟提醒你把视线从显示器上移开。 It should run in the background so when a user clicks on the close button it should hide the app in the system tray and write "app minimized to tray".它应该在后台运行,因此当用户单击关闭按钮时,它应该将应用程序隐藏在系统托盘中并写入“应用程序最小化到托盘”。 Note, the message should only appear when I click on the close button.请注意,该消息仅应在我单击关闭按钮时出现。 On top of that there's a "minimize to tray" button inside the app itself, which does the same thing but doesn't show a pop up message.最重要的是,应用程序本身内部有一个“最小化到托盘”按钮,它做同样的事情但不显示弹出消息。

So I created a.exe file for my app and I also wanted to create an installer.所以我为我的应用程序创建了一个 .exe 文件,我还想创建一个安装程序。 I used NSIS which was simple enough.我使用了非常简单的 NSIS。 But there's a weird behavior after using this app for a couple of times.但是在使用这个应用程序几次后出现了一个奇怪的行为。

Here's how the app should function, and it does work like this when I run the portable version:这是应用程序应该如何 function,当我运行便携式版本时它确实像这样工作:

在此处输入图像描述

I used pyinstall to create a --onefile .exe for this.我使用pyinstall为此创建了一个--onefile .exe。

Now here's the app that I installed using my NSIS installer:现在这是我使用 NSIS 安装程序安装的应用程序:

在此处输入图像描述

As you can see, it activates windows focus assist for some reason, which prevents the app to show the notifications.如您所见,它出于某种原因激活了 windows 焦点辅助,这会阻止应用程序显示通知。 Right off that, after installing the app, it does seem to work fine.马上,安装应用程序后,它似乎工作正常。 The whole notifications mute happens after running it 5-6 times in a row.整个通知静音发生在连续运行 5-6 次后。 Re installing the app seems to solve the issue, but once again, only for a few runs.重新安装该应用程序似乎可以解决问题,但再一次,只运行了几次。 After that the issue returns.之后问题又回来了。

I tried to recreate the issue with the portable version, but couldn't.我试图用便携式版本重新创建问题,但不能。 It works fine.它工作正常。 I believe it has something to do with the NSIS process.我认为这与 NSIS 流程有关。

Here's the NSIS script: https://pastebin.com/x2PjahCC这是 NSIS 脚本: https://pastebin.com/x2PjahCC

Here's the.ini file: https://pastebin.com/ptYKZGbZ这是.ini文件: https://pastebin.com/ptYKZGbZ

Read https://docs.microsoft.com/en-us/windows/win32/shell/enable-desktop-toast-with-appusermodelid - Apparently, you need set the AppUserModelID - now how you successfully get this working with NSIS is beyond me.阅读https://docs.microsoft.com/en-us/windows/win32/shell/enable-desktop-toast-with-appusermodelid - 显然,您需要设置 AppUserModelID - 现在您如何成功使用 NSIS 已经超出了我。 Try: https://nsis.sourceforge.io/WinShell_plug-in or https://github.com/safing/nsis-shortcut-properties and I cant see either making an app available as a priority app.尝试: https://nsis.sourceforge.io/WinShell_plug-inhttps://github.com/safing/nsis-shortcut-properties并且我看不到将应用程序作为优先应用程序提供。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM