本帖最后由 黄薛海 于 2024-10-22 17:17 编辑
Cheat Engine 7.5 修改内存的方式
https://www.123684.com/s/fACrVv-OJw93
[Python] 纯文本查看 复制代码 from pywinauto.application import Application
import time
import psutil
def set_bolttorque_gui_values():
try:
# 启动 BoltTorque.exe 程序
app = Application(backend="uia").start('BoltTorque.exe')
# 连接到主窗口
main_window = app.window(title='BoltTorque 2024b Personal') # 根据实际情况调整窗口标题
main_window.wait('ready', timeout=5) # 等待主窗口准备好
# 螺栓标准
combo_box = main_window.child_window(auto_id="MainWindow.centralwidget.tabWidget.qt_tabwidget_stackedwidget.tab.comboBox_2", control_type="ComboBox")
combo_box.select("GB5789-86")
# 螺栓规格
combo_box = main_window.child_window(auto_id="MainWindow.centralwidget.tabWidget.qt_tabwidget_stackedwidget.tab.comboBox", control_type="ComboBox")
combo_box.select("M12")
# 性能等级
combo_box = main_window.child_window(auto_id="MainWindow.centralwidget.tabWidget.qt_tabwidget_stackedwidget.tab.comboBox_3", control_type="ComboBox")
combo_box.select("10.9")
# 摩擦系数最小/大值
for edit_auto_id, new_value in [("MainWindow.centralwidget.tabWidget.qt_tabwidget_stackedwidget.tab.lineEdit", "0.18"),
("MainWindow.centralwidget.tabWidget.qt_tabwidget_stackedwidget.tab.lineEdit_2", "0.12")]:
line_edit = main_window.child_window(auto_id=edit_auto_id, control_type="Edit")
line_edit.set_text(new_value) # 直接设置新值,无需清空
# 计算类型
combo_box = main_window.child_window(auto_id="MainWindow.centralwidget.groupBox.comboBox_4", control_type="ComboBox")
combo_box.select("已知额定扭矩")
# 额定扭矩MA0 [N.m]
line_edit = main_window.child_window(auto_id="MainWindow.centralwidget.groupBox.lineEdit_3", control_type="Edit")
line_edit.set_text("100") # 设置新的值
# 扭矩上下偏差
line_edit = main_window.child_window(auto_id="MainWindow.centralwidget.groupBox.lineEdit_4", control_type="Edit")
line_edit.set_text("10") # 设置新的值
# 点击按钮 确定
button = main_window.child_window(auto_id="MainWindow.centralwidget.groupBox_2.pushButton", control_type="Button")
button.click() # 点击按钮
# 等待特定进程结束
process_id = app.process # 获取进程的 PID
while True:
time.sleep(0.1) # 定期检查,每0.1秒检查一次
try:
proc = psutil.Process(process_id) # 尝试获取进程
proc.status() # 查询进程状态
except psutil.NoSuchProcess:
break # 如果进程不存在则跳出循环
except Exception as e:
print(f"发生错误: {e}")
if __name__ == "__main__":
set_bolttorque_gui_values()
|