'How can I bring my Cheat Engine character to life with Python

Hello I leave my thanks in advance if anyone can help me 😰. So my english is being translated by my keyboard so excuse the spelling mistakes. It's been 5 months and I still haven't fixed it. I made a little progress now I can read the value, but for that I have to open the cheat engine and copy this address that always changes, I wanted to know how do I find the calculation logic to find this address automatically.print in cheat-engine

from ast import Num
import ctypes as c
from ctypes import wintypes as w
import ctypes
from time import time
from ReadWriteMemory import ReadWriteMemory
import psutil
from typing import Any,  List, NewType
import time
import os

process_name = "TheIsleClient-Win64-Shipping.exe"
pid = None

for proc in psutil.process_iter():
    if process_name in proc.name():
       pid = proc.pid


k32 = c.windll.kernel32

OpenProcess = k32.OpenProcess
OpenProcess.argtypes = [w.DWORD,w.BOOL,w.DWORD]
OpenProcess.restype = w.HANDLE

ReadProcessMemory = k32.ReadProcessMemory
ReadProcessMemory.argtypes = [w.HANDLE,w.LPCVOID,w.LPVOID,c.c_size_t,c.POINTER(c.c_size_t)]
ReadProcessMemory.restype = w.BOOL

WriteMemory = k32.WriteProcessMemory
WriteMemory.argtypes = [w.HANDLE,w.LPCVOID,w.LPVOID,c.c_size_t,c.POINTER(c.c_size_t)]
WriteMemory.restype = w.BOOL

GetLastError = k32.GetLastError
GetLastError.argtypes = None
GetLastError.restype = w.DWORD

CloseHandle = k32.CloseHandle
CloseHandle.argtypes = [w.HANDLE]
CloseHandle.restype = w.BOOL

while True:
    processHandle2 = OpenProcess(0x20, False, pid)
    processHandle = OpenProcess(0x10, False, pid)
    #base 1D22EE665C0
    offsets = [0x30, 0x250, 0x130, 0x20, 0x258, 0x260, 0x734]
    addr = 0x227F820AA34  # .exe module base address
    data = c.c_ulonglong()
    bytesRead = c.c_ulonglong()
    result = ReadProcessMemory(processHandle, addr, c.byref(data), c.sizeof(data), c.byref(bytesRead))
    e = GetLastError()
    #40A000000000002E
    #000000C800000AF0
    #0xc800000af0
    #0x40800000000000c8

    numHex = 0
    numHex1 = 0

    num = str(hex(data.value))
    tam = len(num)
    numR = num[tam-5:tam]
    numHex = int(numR, 16)
    verif = numHex
    #print(numHex)
    if numHex == verif:
        os.system('cls')
        print(numHex)
        time.sleep(1)
        if numHex == verif:
            time.sleep(1)
    else:
        print(numHex)
    '''
    print("TESTE", numHex)
    print("ESSE NUMERO: ", numR)
    print('result: {}, err code: {}, bytesRead: {}'.format(result,e,bytesRead.value))
    print('data: {:016X}'.format(data.value))
    '''
    CloseHandle(processHandle)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source