Skip to content
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
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"markdown-preview-enhanced.revealjsTheme": "black.css",
"markdown-preview-enhanced.previewTheme": "atom-dark.css",
"files.associations": {
"*.qss": "css"
"*.qss": "css",
"*.gui": "json"
},
"gitLineAuthor.colorConfigs": [
{
Expand Down
11 changes: 11 additions & 0 deletions Gui/hooks/zip_json.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import json
import sys

def zip_json(json_file):
with open(json_file, 'r') as f:
data = json.load(f)
with open(json_file, 'w') as f:
json.dump(data, f, ensure_ascii=False)

if __name__ == '__main__':
zip_json(sys.argv[1])
7 changes: 2 additions & 5 deletions Gui/install_pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -832,12 +832,14 @@ def closeEvent(self, event):
shared_memory = QSharedMemory(mem_id[2])
if shared_memory.attach():
# 已经有一个实例在运行
QMessageBox.critical(None, get_init_lang('1d'), get_init_lang('33'))
sys.exit(2)
shared_memory.create(1)

is_running = any(list(map(lambda x: QSharedMemory(x).attach(), mem_id[3:4])))
if is_running:
# 已经有一个实例在运行
QMessageBox.critical(None, get_init_lang('1d'), get_init_lang('31'))
sys.exit(2)

is_ipk = '--ipk' in app.arguments()
Expand Down Expand Up @@ -886,11 +888,6 @@ def closeEvent(self, event):
sys.exit(1)

if is_admin():
is_running = any(list(map(lambda x: QSharedMemory(x).attach(), mem_id[3:4])))
if is_running:
# 已经有一个实例在运行
sys.exit(2)

has_package = os.path.exists(get_resource_path('packages'))
if not has_package:
QMessageBox.warning(None, get_ipk_lang('1d'), get_ipk_lang('1f'))
Expand Down
95 changes: 70 additions & 25 deletions Gui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from uiStyles import indexes as style_indexes # 界面组件样式索引
from sharelibs import (run_software, langs, create_shortcut, __version__, is_pre, get_icon, default_button_text,
get_unit_value, unit_lang, get_size_text, get_file_hash, system_lang, settings, QtThread,
default_settings, mem_id, get_resource_path, run_as_admin, get_lang, multi_replace) # 共享库
default_settings, mem_id, get_resource_path, run_as_admin, get_lang, set_style, compile_ui, UIWindow) # 共享库
import parse_dev # 解析开发固件配置
import winreg # 注册表库
import math # 数学库
Expand Down Expand Up @@ -251,20 +251,6 @@ def get_now_filetime():
little_endian = struct.pack('<Q', filetime_value)
return little_endian

def set_style(widget: QWidget, class_name: str):
'''
设置按钮的class属性并刷新样式
'''
# 1. 设置class属性
widget.setProperty('class', class_name)

# 2. 强制样式刷新
widget.style().unpolish(widget)
widget.style().polish(widget)

# 3. 触发重绘
widget.update()

def get_soft_size():
'''
获取软件大小
Expand Down Expand Up @@ -787,13 +773,13 @@ def click_loop():
break
if not self.paused:
try:
pyautogui.click(button=button)
sleep(delay / 1000)
i += 1
if times == float('inf'):
self.click_conuter.emit('inf', str(i), str(delay))
else:
self.click_conuter.emit(str(times), str(i), str(delay))
pyautogui.click(button=button)
sleep(delay / 1000)
i += 1
except Exception:
trace = format_exc()
MessageBox.critical(None, get_lang('14'), f'{get_lang('1b')}\n{trace}')
Expand Down Expand Up @@ -2169,16 +2155,19 @@ def __init__(self):
self.setWindowFlags(
Qt.Window | Qt.WindowMinimizeButtonHint | Qt.WindowCloseButtonHint
) # 设置窗口属性

self.setFixedSize(self.width(), self.height()) # 固定窗口大小

logger.debug('Initizalizing value')
self.total_run_time = 0 # 总运行时间

logger.debug('Initizalizing ui')
self.init_ui()

if dev_flags.get('decoupling', False):
self.init_ui()
else:
self.init_ui_old()

def init_ui(self):
def init_ui_old(self):
# 创建主控件和布局
central_layout = QVBoxLayout()

Expand Down Expand Up @@ -2235,6 +2224,28 @@ def init_ui(self):
self.times_combo.currentIndexChanged.connect(lambda: self.sync_input(QComboBox.currentIndex, QComboBox.setCurrentIndex, self.times_combo, main_window.times_combo))

logger.debug('Initizalizing fast set click window successful.')

def init_ui(self):
self.ui = UIWindow(compile_ui(get_resource_path('ui', 'fastClick.gui')))

self.ui.find_widget('central_layout.unit_layout.delay_combo').addItems([get_lang('ms', source=unit_lang), get_lang('s', source=unit_lang)])
self.ui.find_widget('central_layout.unit_layout.times_combo').addItems([get_lang('66'), get_lang('2a'), get_lang('2b')])
self.ui.find_widget('central_layout.total_time_label').setText(main_window.total_time_label.text())
self.ui.find_widget('central_layout.total_time_label').setAlignment(Qt.AlignHCenter)

self.setLayout(self.ui.draw({
'central_layout.unit_layout.input_delay': {'textChanged': lambda: self.sync_input(QLineEdit.text, QLineEdit.setText, self.ui.find_widget('central_layout.unit_layout.input_delay'), main_window.input_delay)},
'central_layout.unit_layout.input_times': {'textChanged': lambda: self.sync_input(QLineEdit.text, QLineEdit.setText, self.ui.find_widget('central_layout.unit_layout.input_times'), main_window.input_times)},
'central_layout.unit_layout.delay_combo': {'currentIndexChanged': lambda: self.sync_input(QComboBox.currentIndex, QComboBox.setCurrentIndex, self.ui.find_widget('central_layout.unit_layout.delay_combo'), main_window.delay_combo)},
'central_layout.unit_layout.times_combo': {'currentIndexChanged': lambda: self.sync_input(QComboBox.currentIndex, QComboBox.setCurrentIndex, self.ui.find_widget('central_layout.unit_layout.times_combo'), main_window.times_combo)},
}))

# 主窗口同步 主窗口独立文件没有完成
main_window.input_delay.textChanged.connect(lambda: self.sync_input(QLineEdit.text, QLineEdit.setText, main_window.input_delay, self.ui.find_widget('central_layout.unit_layout.input_delay')))
main_window.input_times.textChanged.connect(lambda: self.sync_input(QLineEdit.text, QLineEdit.setText, main_window.input_times, self.ui.find_widget('central_layout.unit_layout.input_times')))
main_window.delay_combo.currentIndexChanged.connect(lambda: self.sync_input(QComboBox.currentIndex, QComboBox.setCurrentIndex, main_window.delay_combo, self.ui.find_widget('central_layout.unit_layout.delay_combo')))
main_window.times_combo.currentIndexChanged.connect(lambda: self.sync_input(QComboBox.currentIndex, QComboBox.setCurrentIndex, main_window.times_combo, self.ui.find_widget('central_layout.unit_layout.times_combo')))
main_window.total_time_label.textChanged.connect(lambda: self.sync_input(QLabel.text, QLabel.setText, main_window.total_time_label, self.ui.find_widget('central_layout.total_time_label')))

def sync_input(self, get_handle, set_handle, source, dest):
'''同步输入框'''
Expand All @@ -2248,12 +2259,22 @@ def __init__(self):

# 定义变量
self.timer = QTimer(self)
self.timer.timeout.connect(self.update_attr)
self.timer.timeout.connect(self.update_attr if dev_flags.get('decoupling', False) else self.update_attr_old)
self.timer.start(setting_value.soft_delay)

self.init_ui()
if dev_flags.get('decoupling', False):
self.init_ui()
else:
self.init_ui_old()

def init_ui(self):
self.layout_list = UIWindow(compile_ui(get_resource_path('ui', 'clickattr.gui')))

self.setLayout(self.layout_list.draw({"central_layout.bottom_layout.ok_button": {"clicked": self.close}}))

logger.debug('Initizalizing click attribute window successful.')

def init_ui_old(self):
# 创建主布局
central_layout = QVBoxLayout()

Expand Down Expand Up @@ -2287,10 +2308,33 @@ def init_ui(self):

self.setLayout(central_layout)

logger.debug('Initizalizing click attribute window successful.')

def update_attr(self):
'''更新属性'''
logger.debug('update attribute')
left_clicked = self.layout_list.find_widget('central_layout.left_clicked')
right_clicked = self.layout_list.find_widget('central_layout.right_clicked')
click_delay = self.layout_list.find_widget('central_layout.click_delay')
click_times = self.layout_list.find_widget('central_layout.click_times')
paused = self.layout_list.find_widget('central_layout.paused')
stopped = self.layout_list.find_widget('central_layout.stopped')
total_run_time = self.layout_list.find_widget('central_layout.total_run_time')

left_clicked.setText(f'{get_lang('0c')}: {get_lang('7b') if clicker.left_clicked else get_lang('7c')}')
right_clicked.setText(f'{get_lang('0d')}: {get_lang('7b') if clicker.right_clicked else get_lang('7c')}')
click_delay.setText(f'{get_lang('78')}: {delay_num}{get_lang('ms', source=unit_lang)}')
click_times.setText(f'{get_lang('5c')}: {get_lang('2b') if is_inf else time_num}')
paused.setText(f'{get_lang('0f')}: {get_lang('79') if clicker.paused else get_lang('7a')}')
stopped.setText(f'{get_lang('0e')}: {get_lang('79') if not clicker.running else get_lang('7a')}')
try:
if is_inf:
total_run_time.setText(f'{get_lang('2c')}: {get_lang('2b')}')
else:
total_run_time.setText(f'{get_lang('2c')}: {main_window.total_run_time[0]:.2f}{main_window.total_run_time[1]}')
except TypeError:
value = get_unit_value(main_window.total_run_time)
total_run_time.setText(f'{get_lang('2c')}: {value[0]:.2f}{value[1]}')

def update_attr_old(self):
logger.debug('update attribute')
self.left_clicked.setText(f'{get_lang('0c')}: {get_lang('7b') if clicker.left_clicked else get_lang('7c')}')
self.right_clicked.setText(f'{get_lang('0d')}: {get_lang('7b') if clicker.right_clicked else get_lang('7c')}')
Expand Down Expand Up @@ -3424,6 +3468,7 @@ def on_start(self):
shared_memory = QSharedMemory(mem_id[0])
if shared_memory.attach():
# 已经有一个实例在运行
QMessageBox.critical(None, get_lang('14'), get_lang('d6'))
sys.exit(2)
shared_memory.create(1)

Expand Down
5 changes: 5 additions & 0 deletions Gui/res/dev_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,10 @@
"name": "More settings",
"key": "new_settings",
"desc": "To add more settings include:\nToast settings\nEnable hotkey checkbox\nFeedback settings and more..."
},
{
"name": "Decoupling UI and program",
"key": "decoupling",
"desc": "To decouple the UI and program.This need to restart the program to take effect."
}
]
4 changes: 2 additions & 2 deletions Gui/res/langs/control.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"05": "The program has successfully uninstalled, but some contents may remain, please delete this folder: {0}",
"06": "Do you want to uninstall clickmouse and its related components?",
"07": "Please run this program as an administrator.",
"08": "Clickmouse is running, please close it before trying to fix it",
"08": "There is already a clickmouse instance running, please close it. if you can't find the window, you can wake it up from the tray.",
"09": "Do you want to fix clickmouse?",
"0a": "Fix successful.",
"0b": "Clickmouse Repair Tool",
Expand Down Expand Up @@ -45,7 +45,7 @@
"05": "程序已成功卸载,但是部分内容可能有残留,请删除这个文件夹:{0}",
"06": "是否卸载clickmouse和其相关组件?",
"07": "请以管理员身份运行本程序。",
"08": "Clickmouse正在运行,请关闭后再尝试修复",
"08": "已经有一个clickmouse相关实例在运行,请先关闭它,如果你没有找到窗口,可前往托盘唤醒。",
"09": "是否修复Clickmouse?",
"0a": "修复成功。",
"0b": "clickmouse 修复工具",
Expand Down
8 changes: 6 additions & 2 deletions Gui/res/langs/init.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@
"2d": "\nStart menu shortcut",
"2e": "Checking for update files...",
"2f": "No package change",
"30": "Current status:"
"30": "Current status:",
"31": "There is already a uninstall or repair program instance running, please close it.",
"33": "There is already a modify program instance running."
}
},
{
Expand Down Expand Up @@ -104,7 +106,9 @@
"2d": "\n开始菜单快捷方式",
"2e": "检查需要更新的文件...",
"2f": "没有包变动",
"30": "当前状态:"
"30": "当前状态:",
"31": "已经有一个卸载或修复程序实例在运行,请先关闭它。",
"33": "已经有一个修改程序实例在运行。"
}
}
]
6 changes: 4 additions & 2 deletions Gui/res/langs/langs.json
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@
"d2": "Repair successfully.",
"d3": "Lab",
"d4": "To test some experimental features, which may not be stable.",
"d5": "Hide \"lab\" when no experimental features"
"d5": "Hide \"lab\" when no experimental features",
"d6": "There is already an instance running, if you can't find the window, you can wake it up from the tray."
}
},
{
Expand Down Expand Up @@ -426,7 +427,8 @@
"d2": "修复成功。",
"d3": "实验室",
"d4": "用于测试一些功能,可能不稳定。",
"d5": "无实验项时候隐藏\"实验室\"设置项"
"d5": "无实验项时候隐藏\"实验室\"设置项",
"d6": "已经有一个实例在运行,如果你没有找到窗口,可前往托盘唤醒。"
}
}
]
1 change: 1 addition & 0 deletions Gui/res/ui/clickattr.gui
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name": "central_layout", "value": {"direction": "v", "content": [{"name": "left_clicked", "value": {"type": "QLabel", "arg": ["!lang 0d"]}}, {"name": "right_clicked", "value": {"type": "QLabel", "arg": ["!lang 0e"]}}, {"name": "click_delay", "value": {"type": "QLabel", "arg": ["!lang 78"]}}, {"name": "click_times", "value": {"type": "QLabel", "arg": ["!lang 5c"]}}, {"name": "paused", "value": {"type": "QLabel", "arg": ["!lang 71"]}}, {"name": "stopped", "value": {"type": "QLabel", "arg": ["!lang 73"]}}, {"name": "total_run_time", "value": {"type": "QLabel", "arg": ["!lang 2c"]}}, {"name": "bottom_layout", "value": {"direction": "h", "stretch": true, "content": [{"name": "ok_button", "value": {"type": "QPushButton", "arg": ["!lang 1e"], "style": "selected"}}]}}]}}
1 change: 1 addition & 0 deletions Gui/res/ui/fastClick.gui
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name": "central_layout", "value": {"direction": "v", "content": [{"name": "unit_layout", "value": {"direction": "u", "texts": ["!lang 11", "!lang 5c"], "inputs": [{"name": "input_delay", "value": {"type": "QLineEdit", "init_steps": {"setFixedWidth": [300], "setFixedHeight": [30]}}}, {"name": "input_times", "value": {"type": "QLineEdit", "init_steps": {"setFixedWidth": [300], "setFixedHeight": [30]}}}], "combos": [{"name": "delay_combo", "value": {"type": "QComboBox", "init_steps": {"setFixedWidth": [60], "setFixedHeight": [30]}}}, {"name": "times_combo", "value": {"type": "QComboBox", "init_steps": {"setFixedWidth": [60], "setFixedHeight": [30]}}}]}}, {"name": "total_time_label", "value": {"type": "QLabel", "style": "big_text_16"}}]}}
2 changes: 1 addition & 1 deletion Gui/res/versions.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"package_format_version": "1.2.0", "clickmouse":"3.3.0.22alpha4"}
{"clickmouse":"3.3.0.23alpha5"}
2 changes: 1 addition & 1 deletion Gui/runhook.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
@echo off

py hooks/%1.py
py hooks/%1.py %2
Loading
Loading