用python使用pymem库制作辅助工具
一、工具:1、python2、pymen库3、pyside2库4、designer界面设计工具二、软件界面三、视频效果四、代码展示:五、界面设计图
·
一、工具:
1、python
2、pymen库
3、pyside2库
4、designer界面设计工具
5、植物大战僵尸中文版
二、软件界面
三、视频效果
增加指定位置和指定种植植物的功能等效果如下图:(代码可私信)
四、代码展示:
from PySide2.QtWidgets import QApplication
from PySide2.QtUiTools import QUiLoader
from PySide2.QtCore import QFile
from pymem import * #操作内存库
class Stats: #定义类
def __init__(self): #导入UI窗口
#从文件中加载UI界面
qfle_stats=QFile('植物大战僵尸V2.1.ui') #导入UI界面固定写法
qfle_stats.open(QFile.ReadOnly) #导入UI界面固定写法
qfle_stats.close() #导入UI界面固定写法
self.ui=QUiLoader().load(qfle_stats) #定义窗口
self.ui.pushButton.clicked.connect(self.yangguang) #按纽点击函数 BUtton要与界面中的按纽名字一致
self.ui.pushButton_2.clicked.connect(self.yangguang2) # 修改阳光值
self.ui.pushButton_4.clicked.connect(self.jingbi1) # 查询金币
self.ui.pushButton_3.clicked.connect(self.jingbi) # 修改金币
self.ui.pushButton_5.clicked.connect(self.gongji1) # 查询攻击力
self.ui.pushButton_6.clicked.connect(self.gongji) # 修改攻击力
self.ui.pushButton_9.clicked.connect(self.miaosha) # 秒杀僵尸
self.ui.buttonGroup.buttonClicked.connect(self.cd) #冷却CD
self.ui.buttonGroup_2.buttonClicked.connect(self.pao) # 所有植物加农炮
self.ui.buttonGroup_3.buttonClicked.connect(self.jshi) # 僵尸快速出击
self.ui.buttonGroup_4.buttonClicked.connect(self.jbi) # 金币自动收集
self.ui.buttonGroup_5.buttonClicked.connect(self.houtai) # 后台运行
self.pymem = Pymem("PlantsVsZombies.exe") #植物大战僵尸游戏名
def yangguang(self): #查询阳光值
addr = self.pymem.read_int(0x6a9ec0) #基址
addr = self.pymem.read_int(addr + 0x768) #第一次偏移
addr = self.pymem.read_int(addr + 0x5560) #第一次偏移
print('阳光值')
print(addr)
self.ui.lineEdit_3.setText(str(addr))
def yangguang2(self): #阳光值
changeSun= int(self.ui.lineEdit_3.text())
addr = self.pymem.read_int(0x6a9ec0) #基址
addr = self.pymem.read_int(addr + 0x768) #第一次偏移
self.pymem.write_int(addr+0x5560,changeSun)
def jingbi1(self): #查询
addr = self.pymem.read_int(0x6a9ec0) #基址
addr = self.pymem.read_int(addr + 0x82C) #第一次偏移
showSun=self.pymem.read_int(addr+0x28)
self.ui.lineEdit_4.setText(str(showSun * 10))
def jingbi(self): #改阳光
changeSun = int(int(self.ui.lineEdit_4.text()) / 10) # 金币等于10的整数
addr = self.pymem.read_int(0x6a9ec0) #基址
addr = self.pymem.read_int(addr + 0x82C) #第一次偏移
self.pymem.write_int(addr+0x28,changeSun)
def gongji1(self): #查询攻击力
showSun= self.pymem.read_int(0x69F1C8) # 基址
self.ui.lineEdit_5.setText(str(showSun))
def gongji(self): #改攻击力
changeSun= int(self.ui.lineEdit_5.text())
self.pymem.write_int(0x69F1C8,changeSun)
def cd(self):
button = self.ui.buttonGroup.checkedButton()
text = button.text()
if text == "是":
self.pymem.write_bytes(0x487296,bytes(bytearray.fromhex("74 14")),2) #74 14 为无限CD
elif text == "否":
self.pymem.write_bytes(0x487296, bytes(bytearray.fromhex("7e 14")), 2) # 7e 14 为有CD
def miaosha(self): #秒杀僵尸
print("秒杀")
addr = self.pymem.read_int(0x6a9ec0)
addr = self.pymem.read_int(addr + 0x768)
address1 = self.pymem.read_int(addr + 0x90)
for i in range(0, 1024):
address2=address1+0x28+0x15c*i
print(address2)
self.pymem.write_int(address2,3)
def pao(self): # 所有植物家农炮
button = self.ui.buttonGroup_2.checkedButton()
text = button.text()
if text == "是":
self.pymem.write_uint(0x0046C765, 0x0b5c45c7) # write_uint 等于写内存整数形
self.pymem.write_uint(0x0046C769, 0x8b000000)
elif text == "否":
self.pymem.write_uint(0x0046C765, 0x2424448b) # write_uint 等于写内存整数形
self.pymem.write_uint(0x0046C769, 0x8b5c4589)
def jshi(self): # 僵尸快速出击
button = self.ui.buttonGroup_3.checkedButton()
text = button.text()
if text == "是":
self.pymem.write_bytes(0x413FD9, bytes(bytearray.fromhex("0f 84 0d 01 00 00")),6) # 注:0f 84 0d 01 00 00 为6个16进制的字节值 6表示6个字节
elif text == "否":
self.pymem.write_bytes(0x413FD9, bytes(bytearray.fromhex("0f 85 0d 01 00 00")),6)
def jbi(self): # 自动收集
button = self.ui.buttonGroup_4.checkedButton()
text = button.text()
if text == "是":
self.pymem.write_bytes(0x0043158F,bytes(bytearray.fromhex("74 08")),2)
elif text == "否":
self.pymem.write_bytes(0x0043158F,bytes(bytearray.fromhex("75 08")),2)
def houtai(self): # 自动收集
button = self.ui.buttonGroup_5.checkedButton()
text = button.text()
if text == "是":
self.pymem.write_int(0x4502C0, 195)
elif text == "否":
self.pymem.write_int(0x4502C0, 2213317461)
if "__main__" == __name__:
app = QApplication([])
Stats = Stats()
Stats.ui.show()
app.exec_()
五、界面设计图
更多推荐
已为社区贡献2条内容
所有评论(0)