Skip to content

同步修改 #14

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

Merged
merged 8 commits into from
Dec 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 37 additions & 29 deletions Boss-Key.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,41 +20,49 @@

ctypes.windll.shcore.SetProcessDpiAwareness(2) # Win10 and Win8
ctypes.windll.user32.SetProcessDPIAware() #Win7 and below
def windows_message_box(title, message):
ctypes.windll.user32.MessageBoxW(0, message, title, 0x40 | 0x1)

def write_pid(name):
with open(name, "w") as f:
f.write(str(psutil.Process().pid))
class APP(wx.App):
def __init__(self):
wx.App.__init__(self)

def is_already_running(name):
if os.path.exists(name):
with open(name, "r") as f:
pid=f.read()
if pid == "":
write_pid(name)
else:
try:
process=psutil.Process(int(pid))
if process.is_running():
return True
else:
write_pid(name)
# 设置语言环境为中文
self.locale = wx.Locale(wx.LANGUAGE_CHINESE_SIMPLIFIED)
self.SetAppName(Config.AppName)
self.SetAppDisplayName(Config.AppName)
self.SetVendorName(Config.AppAuthor)
if self.is_already_running(sys.argv[0][:-4]+".lock"):
wx.MessageBox( "Boss Key is already running","Boss Key", wx.OK | wx.ICON_INFORMATION)
sys.exit(0)

def write_pid(self,name):
with open(name, "w") as f:
f.write(str(psutil.Process().pid))

def is_already_running(self,name):
if os.path.exists(name):
with open(name, "r") as f:
pid=f.read()
if pid == "":
self.write_pid(name)
else:
try:
process=psutil.Process(int(pid))
if process.is_running():
return True
else:
self.write_pid(name)
return False
except:
self.write_pid(name)
return False
except:
write_pid(name)
return False
else:
write_pid(name)
else:
self.write_pid(name)

if is_already_running(sys.argv[0][:-4]+".lock"):
windows_message_box("Boss Key", "Boss Key is already running")
sys.exit(0)
else:
app = wx.App()
if __name__ == '__main__':
app = APP()
Config.TaskBarIcon=taskbar.TaskBarIcon()
Config.HotkeyWindow=listener.HotkeyListener()
Config.SettingWindow=setting.SettingWindow()
Config.TaskBarIcon=taskbar.TaskBarIcon()
if Config.first_start:
Config.SettingWindow.Show()
app.MainLoop()
Expand Down
60 changes: 14 additions & 46 deletions GUI/about.py
Original file line number Diff line number Diff line change
@@ -1,51 +1,19 @@
import wx
import wx.adv

from core.config import Config

class AboutWindow(wx.Dialog):
class AboutWindow():
def __init__(self):
wx.Dialog.__init__(self, None, title="关于 - Boss Key", style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)
self.SetIcon(wx.Icon(wx.Image(Config.icon).ConvertToBitmap()))
self.info = wx.adv.AboutDialogInfo()
self.info.SetName(Config.AppName)
self.info.SetVersion(Config.AppVersion)
self.info.SetIcon(wx.Icon(wx.Image(Config.icon).ConvertToBitmap()))
self.info.SetCopyright(Config.AppCopyRight)
self.info.SetWebSite(Config.AppWebsite)
self.info.SetLicence(Config.AppLicense)
self.info.AddDeveloper(Config.AppAuthor)
self.info.SetDescription(Config.AppDescription)

self.init_UI()
self.SetSize((500, 500))

self.Center()

def init_UI(self):
# 创建面板
panel = wx.Panel(self)
vbox = wx.BoxSizer(wx.VERTICAL)

#设置图标
IconHbox = wx.BoxSizer(wx.HORIZONTAL)
icon = wx.StaticBitmap(panel, bitmap=wx.Bitmap(Config.icon_info))
IconHbox.Add(icon, proportion=1, flag=wx.LEFT, border=10)
vbox.Add(IconHbox, proportion=1, flag=wx.EXPAND, border=10)

#设置标题
TitleHbox = wx.BoxSizer(wx.HORIZONTAL)
title = wx.StaticText(panel, label="Boss Key", style=wx.ALIGN_CENTER)
title.SetFont(wx.Font(18, wx.FONTFAMILY_MODERN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD))
TitleHbox.Add(title, proportion=1, flag=wx.CENTER)
vbox.Add(TitleHbox, proportion=1, flag=wx.EXPAND)

#设置版本
VersionHbox = wx.BoxSizer(wx.HORIZONTAL)
version = wx.StaticText(panel, label=f"版本: {Config.AppVersion} 发布于:{Config.AppReleaseDate}", style=wx.ALIGN_CENTER)
VersionHbox.Add(version, proportion=1, flag=wx.CENTER)
vbox.Add(VersionHbox, proportion=1, flag=wx.EXPAND)

#设置作者
AuthorHbox = wx.BoxSizer(wx.HORIZONTAL)
author = wx.StaticText(panel, label=f"作者: {Config.AppAuthor}", style=wx.ALIGN_CENTER)
AuthorHbox.Add(author, proportion=1, flag=wx.CENTER)
vbox.Add(AuthorHbox, proportion=1, flag=wx.EXPAND)

#设置版权
copyrightHbox = wx.BoxSizer(wx.HORIZONTAL)
copyright= wx.StaticText(panel, label=Config.AppCopyRight, style=wx.ALIGN_CENTER)
copyrightHbox.Add(copyright, proportion=1, flag=wx.CENTER)
vbox.Add(copyrightHbox, proportion=1, flag=wx.EXPAND)

panel.SetSizer(vbox)
self.Layout()
def Show(self):
wx.adv.AboutBox(self.info)
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Ivan Hanloth

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
27 changes: 26 additions & 1 deletion core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,35 @@
import io

class Config:
AppName = "Boss Key"
AppVersion = "1.4.3.0"
AppReleaseDate = "2024-12-19"
AppAuthor = "IvanHanloth"
AppCopyRight = "Copyright © 2024 Ivan Hanloth All Rights Reserved."
AppDescription = "老板来了?快用Boss-Key一键隐藏静音当前窗口!上班摸鱼必备神器"
AppCopyRight = "Copyright © 2022-2025 Ivan Hanloth All Rights Reserved."
AppWebsite = "https://github.com/IvanHanloth/Boss-Key"
AppLicense = """MIT License

Copyright (c) 2022 Ivan Hanloth

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""

hwnd=0
hwnd_b = ""
Expand Down
7 changes: 5 additions & 2 deletions core/tools.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from winreg import OpenKey,HKEY_CURRENT_USER,QueryValueEx,DeleteValue,CloseKey,KEY_ALL_ACCESS,SetValueEx,REG_SZ
from win11toast import notify
import wx.adv
from pycaw.pycaw import AudioUtilities, ISimpleAudioVolume
from core.config import Config
import win32process
Expand Down Expand Up @@ -60,7 +60,10 @@ def changeMute(hwnd,flag=1):
break

def sendNotify(title,message):
notify(title,message,icon=Config.icon_info,duration="short")
notify = wx.adv.NotificationMessage(title=title,message=message,parent=None)
notify.SetIcon(wx.Icon(wx.Image(Config.icon).ConvertToBitmap()))
notify.UseTaskBarIcon(Config.TaskBarIcon)
notify.Show(timeout=3) # 1 for short timeout, 100 for long timeout

def keyMux(key):
"""
Expand Down