;#Include <Memory.au3>
$CurProcID = ProcessExists("ClientGUI_r.exe") ; 取得PID供内存调用
$Handle = _MemoryOpen($CurProcID) ;使用UDF取得PID的内存操作句柄
MsgBox(0, "指南", $CurProcID)
MsgBox(0, "指南", $Handle)
$Address1=0x014e7684 ;基址--战斗状态
$Address1 = _MemoryRead("0x" & Hex($Address1+0x28), $Handle) ;读取基址数据
$Address1 = _MemoryRead("0x" & Hex($Address1+0x2c), $Handle) ;读取基址数据
$Address1 = _MemoryRead("0x" & Hex($Address1+0xa5), $Handle) ;读取基址数据
$Address2=0x018ccec4 ;红
$Address2 = _MemoryRead("0x" & Hex($Address2+0x34), $Handle)
$Address2 = _MemoryRead("0x" & Hex($Address2+0xe4), $Handle)
$Address3=0x018ccec4 ;最大红
$Address3 = _MemoryRead("0x" & Hex($Address3+0x34), $Handle)
$Address3 = _MemoryRead("0x" & Hex($Address3+0xdc), $Handle)
$Address4=0x018ccec4 ;兰
$Address4 = _MemoryRead("0x" & Hex($Address4+0x34), $Handle)
$Address4 = _MemoryRead("0x" & Hex($Address4+0xf8), $Handle)
$Address5=0x018ccec4 ;最大兰
$Address5 = _MemoryRead("0x" & Hex($Address5+0x34), $Handle)
$Address5 = _MemoryRead("0x" & Hex($Address5+0xf0), $Handle)
MsgBox(0, "指南", $Address5)
While 1
$zd = _MemoryRead("0x" & Hex($Address1), $Handle) ;获得战斗状态
$hy = _MemoryRead("0x" & Hex($Address2), $Handle)
$zdh = _MemoryRead("0x" & Hex($Address3), $Handle)
$ly = _MemoryRead("0x" & Hex($Address4), $Handle)
$zdl = _MemoryRead("0x" & Hex($Address5), $Handle)
If $zd=0 Then
if $hy<$zdh then
send("{f1}")
EndIf
if $ly<$zdl Then
send("{f2}")
EndIf
EndIf
sleep (1000)
Wend
Func _MemoryOpen($iv_Pid, $iv_DesiredAccess = 0x1F0FFF, $if_InheritHandle = 1)
If Not ProcessExists($iv_Pid) Then
SetError(1)
Return 0
EndIf
Local $ah_Handle[2] = [DllOpen('kernel32.dll')]
If @Error Then
SetError(2)
Return 0
EndIf
Local $av_OpenProcess = DllCall($ah_Handle[0], 'int', 'OpenProcess', 'int', $iv_DesiredAccess, 'int', $if_InheritHandle, 'int', $iv_Pid)
If @Error Then
DllClose($ah_Handle[0])
SetError(3)
Return 0
EndIf
$ah_Handle[1] = $av_OpenProcess[0]
Return $ah_Handle
EndFunc
;=================================================================================================
Func _MemoryRead($iv_Address, $ah_Handle, $sv_Type = 'dword')
If Not IsArray($ah_Handle) Then
SetError(1)
Return 0
EndIf
Local $v_Buffer = DllStructCreate($sv_Type)
If @Error Then
SetError(@Error + 1)
Return 0
EndIf
DllCall($ah_Handle[0], 'int', 'ReadProcessMemory', 'int', $ah_Handle[1], 'int', $iv_Address, 'ptr', DllStructGetPtr($v_Buffer), 'int', DllStructGetSize($v_Buffer), 'int', '')
If Not @Error Then
Local $v_Value = DllStructGetData($v_Buffer, 1)
Return $v_Value
Else
SetError(6)
Return 0
EndIf
EndFunc
;=================================================================================================
Func _MemoryClose($ah_Handle)
If Not IsArray($ah_Handle) Then
SetError(1)
Return 0
EndIf
DllCall($ah_Handle[0], 'int', 'CloseHandle', 'int', $ah_Handle[1])
If Not @Error Then
DllClose($ah_Handle[0])
Return 1
Else
DllClose($ah_Handle[0])
SetError(2)
Return 0
EndIf
EndFunc
;=================================================================================================
Func _MemoryWrite($iv_Address, $ah_Handle, $v_Data, $sv_Type = 'dword')
If Not IsArray($ah_Handle) Then
SetError(1)
Return 0
EndIf
Local $v_Buffer = DllStructCreate($sv_Type)
If @Error Then
SetError(@Error + 1)
Return 0
Else
DllStructSetData($v_Buffer, 1, $v_Data)
If @Error Then
SetError(6)
Return 0
EndIf
EndIf
DllCall($ah_Handle[0], 'int', 'WriteProcessMemory', 'int', $ah_Handle[1], 'int', $iv_Address, 'ptr', DllStructGetPtr($v_Buffer), 'int', DllStructGetSize($v_Buffer), 'int', '')
If Not @Error Then
Return 1
Else
SetError(7)
Return 0
EndIf
EndFunc