zoukankan      html  css  js  c++  java
  • py 使用win32 api

    安装 pywin32

    pip install pywin32 -i https://pypi.tuna.tsinghua.edu.cn/simple
    

    使用

    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
    
  • 相关阅读:
    结构型模式(一) 适配器模式
    选择器
    CSS引入
    CSS语法
    CSS介绍
    HTML练习
    HTML标签嵌套规则(重点)
    HTML标签分类(重点)
    HTML标签属性
    body标签
  • 原文地址:https://www.cnblogs.com/ajanuw/p/13610374.html
Copyright © 2011-2022 走看看