py 使用win32 api
阅读原文时间:2023年07月09日阅读:1

main.py

import win32api
import win32com.client

win32api.MessageBox(0, "body", "caption", 0)

speack = win32com.client.Dispatch("SAPI.SpVoice")
speack.Speak("abc")


λ python main.py


from ctypes import *

PROCESS_ALL_ACCESS = 2097151
kernel32 = windll.kernel32

hProcess = kernel32.OpenProcess(PROCESS_ALL_ACCESS, False, 10256)
print("hProcess: ", hProcess)
if hProcess == 0:
  print("OpenProcess error.")
  exit()

val = c_uint32(0)
if kernel32.ReadProcessMemory(hProcess, 0x4B3724, byref(val), sizeof(val), 0) == 0:
  print("ReadProcessMemory error.")
  exit()

print("Current HP: ", val.value)

newval = c_uint32(100)
if kernel32.WriteProcessMemory(hProcess, 0x4B3724, byref(newval), sizeof(newval), 0) == 0:
  print("WriteProcessMemory error.")
  exit()

if kernel32.ReadProcessMemory(hProcess, 0x4B3724, byref(val), sizeof(val), 0) == 0:
  print("ReadProcessMemory error.")
  exit()

print("New HP: ", newval.value)

kernel32.CloseHandle(hProcess)


λ python main.py
hProcess:  496
Current HP:  42
New HP:  100

手机扫一扫

移动阅读更方便

阿里云服务器
腾讯云服务器
七牛云服务器