forked from HaujetZhao/CapsWriter-Offline
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
H1DDENADM1N
committed
Mar 6, 2024
1 parent
b0e224c
commit 873b3fc
Showing
6 changed files
with
85 additions
and
8 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import sys | ||
import win32api | ||
from PySide6.QtWidgets import QApplication, QLabel | ||
from PySide6.QtCore import QTimer, QPoint, Qt | ||
from PySide6.QtGui import QPalette, QColor, QFont | ||
from config import ClientConfig as Config | ||
import keyboard | ||
|
||
class Hint_While_Recording_At_Cursor_Position(QLabel): | ||
def __init__(self): | ||
super().__init__() | ||
self.setWindowFlags(Qt.ToolTip | Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint) | ||
font = QFont("Segoe MDL2 Assets", 14) | ||
self.setFont(font) | ||
palette = self.palette() | ||
palette.setColor(QPalette.Window, QColor("#212121")) # 设置背景颜色 | ||
palette.setColor(QPalette.WindowText, QColor("#00B294")) # 设置文本颜色 | ||
self.setPalette(palette) | ||
self.setVisible(False) # 初始时隐藏标签 | ||
|
||
# 创建一个定时器来定期更新鼠标位置 | ||
self.timer = QTimer(self) | ||
self.timer.timeout.connect(self.update_tooltip_position) | ||
self.timer.start(100) # 每100毫秒更新一次 | ||
|
||
def update_tooltip_position(self): | ||
# 使用pywin32获取全局鼠标位置 | ||
x, y = win32api.GetCursorPos() | ||
# 更新标签的位置和文本 | ||
self.move(x+20, y+20) | ||
if keyboard.is_pressed(Config.speech_recognition_shortcut): | ||
self.setText(chr(0xF8B1)) | ||
self.setVisible(True) | ||
else: | ||
self.setVisible(False) | ||
|
||
if __name__ == "__main__": | ||
app = QApplication(sys.argv) | ||
tooltip = Hint_While_Recording_At_Cursor_Position() | ||
tooltip.show() # 显示标签 | ||
sys.exit(app.exec()) |