i currently have a code for a auto potter,
but i have a problem. in the game QWE will heal HP MP & Poison,
if i use send() it works okay...
but i want to use ControlSend(), because it works even if game window is not focused. but it doesnt work, it doesnt PRESS the QWE, but it will TYPE..
anyway for pressing Q W E on keyboard code that works to an specific window.
but i have a problem. in the game QWE will heal HP MP & Poison,
if i use send() it works okay...
but i want to use ControlSend(), because it works even if game window is not focused. but it doesnt work, it doesnt PRESS the QWE, but it will TYPE..
anyway for pressing Q W E on keyboard code that works to an specific window.
PHP Code:
#include <NomadMemory3.au3>
#include <GUIConstantsEx.au3>
;Local $rNew,$rOld
Local $CurHPOffset[7] = [0, Dec("18570DC"), Dec("4338"), Dec("3C"), Dec("6C"), Dec(0), Dec("C0")]
Local $MaxHPOffset[7] = [0, Dec("18570DC"), Dec("4338"), Dec("3C"), Dec("6C"), Dec(0), Dec("C8")]
Local $CurMPOffset[7] = [0, Dec("18570DC"), Dec("4338"), Dec("3C"), Dec("6C"), Dec(4), Dec("C0")]
Local $MaxMPOffset[7] = [0, Dec("18570DC"), Dec("4338"), Dec("3C"), Dec("6C"), Dec(4), Dec("C8")]
Local $CurEXPOffset[3] = [0, Dec("7198BC"), Dec("128")]
Local $MaxEXPOffset[3] = [0, Dec("7197B4"), Dec("101C")]
Local $KillerOffset[2] = [0, Dec("116")]
$hMemoryOpen = _OpenMemory("KhanClient.exe")
$HPMPfADDR = _GetFinalAddress($hMemoryOpen,"18570DC")
$CurEXPfADDR = _GetFinalAddress($hMemoryOpen,"7198BC")
$MaxEXPfADDR = _GetFinalAddress($hMemoryOpen,"7197B4")
$KillerfADDR = _GetFinalAddress($hMemoryOpen,"3198BC")
$rCurHPold = _ReadFromPointer($HPMPfADDR,$hMemoryOpen,$CurHPOffset)
$rMaxHPold = _ReadFromPointer($HPMPfADDR,$hMemoryOpen,$MaxHPOffset)
$rCurMPold = _ReadFromPointer($HPMPfADDR,$hMemoryOpen,$CurMPOffset)
$rMaxMPold = _ReadFromPointer($HPMPfADDR,$hMemoryOpen,$MaxMPOffset)
$rCurEXPold = _ReadFromPointer($HPMPfADDR,$hMemoryOpen,$CurEXPOffset)
$rMaxEXPold = _ReadFromPointer($HPMPfADDR,$hMemoryOpen,$MaxEXPOffset)
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Khan Tools", 157, 181, 501, 202)
$hp_prog = GUICtrlCreateProgress(15, 20, 121, 16)
$hp_slider = GUICtrlCreateSlider(15, 40, 121, 16)
GUICtrlSetData($hp_slider, 50)
$mp_prog = GUICtrlCreateProgress(15, 65, 121, 16)
$mp_slider = GUICtrlCreateSlider(15, 85, 121, 16)
GUICtrlSetData($mp_slider, 50)
$exp_prog = GUICtrlCreateProgress(15, 120, 121, 16)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
If ProcessExists("KhanClient.exe") = 0 Then
ExitLoop
EndIf
;Declaring Variables
$rCurHPnew = _ReadFromPointer($HPMPfADDR,$hMemoryOpen,$CurHPOffset)
$rMaxHPnew = _ReadFromPointer($HPMPfADDR,$hMemoryOpen,$MaxHPOffset)
$rCurMPnew = _ReadFromPointer($HPMPfADDR,$hMemoryOpen,$CurMPOffset)
$rMaxMPnew = _ReadFromPointer($HPMPfADDR,$hMemoryOpen,$MaxMPOffset)
$rCurEXPnew = _ReadFromPointer($CurEXPfADDR,$hMemoryOpen,$CurEXPOffset)
$rMaxEXPnew = _ReadFromPointer($MaxEXPfADDR,$hMemoryOpen,$MaxEXPOffset)
$hp_perc = Round(($rCurHPnew/$rMaxHPnew)*100, 1)
$mp_perc = Round(($rCurMPnew/$rMaxMPnew)*100, 1)
$exp_perc = Round(($rCurEXPnew/$rMaxEXPnew)*100, 1)
;Setting Default Data
GUICtrlSetData($hp_prog, $hp_perc, "")
GUICtrlSetData($mp_prog, $mp_perc, "")qw
GUICtrlSetData($exp_prog, $exp_perc, "")
;----------------------------------------------------
;Problem here, this works but not as planned.
;----------------------------------------------------
If $hp_perc < GUICtrlRead($hp_slider) Then
Send("{q}")
EndIf
If $mp_perc < GUICtrlRead($mp_slider) Then
Send("{w}")
EndIf
;----------------------------------------------------
; I want it to work even if Khan Power window is not active
;----------------------------------------------------
WEnd
_MemoryClose($hMemoryOpen)
Func _OpenMemory($sProcess)
$aOpen = _MemoryOpen(ProcessExists($sProcess))
If $aOpen = 0 Then
Switch @error
Case 1
MsgBox(0, "Error", "Error opening Process: Process ID is invalid.")
Case 2
MsgBox(0, "Error", "Error opening Process: Failed to open Kernel32.dll.")
Case 3
MsgBox(0, "Error", "Error opening " & $aOpen & ".")
EndSwitch
Exit
EndIf
Return $aOpen
EndFunc
Func _GetFinalAddress($hMemory, $xStaticOffset)
Local $iStaticOffset, $iBaseAddress
$iBaseAddress = _MemoryGetBaseAddress($hMemory, 1)
If $iBaseAddress = 0 Then
Switch @error
Case 1
MsgBox(0, "Error", "Error getting Base Address: Invalid Handle to open Process.")
Case 2
MsgBox(0, "Error", "Error getting Base Address: Failed to find correct allocation Address.")
Case 3
MsgBox(0, "Error", "Error getting Base Address: Failed to read from the specified Process.")
EndSwitch
Exit
EndIf
Return "0x" & Hex($iBaseAddress + Dec($xStaticOffset))
EndFunc
Func _ReadFromPointer($xFinalAddress,$hMemory,$aOffset,$sType = "dword")
Local $aRead
$aRead = _MemoryPointerRead($xFinalAddress, $hMemory, $aOffset, $sType)
If $aRead = 0 Then
Switch @error
Case 1
MsgBox(0, "Error", "Error reading Pointer: The specified Offset isn't an Array")
Case 2
MsgBox(0, "Error", "Error reading Pointer: Invalid Handle to open Process.")
Case 3
MsgBox(0, "Error", "Error reading Pointer: Type is not a String")
Case 4
MsgBox(0, "Error", "Error reading Pointer: Type is unsupported or unknown")
Case 5
MsgBox(0, "Error", "Error reading Pointer: Failed to allocate the memory needed for the DllStructure")
Case 6
MsgBox(0, "Error", "Error reading Pointer: Failed to allocate the memory needed for " & $sType)
Case 7
MsgBox(0, "Error", "Error reading Pointer: Failed to read from the specified Process")
EndSwitch
Exit
Else
Return $aRead[1]
EndIf
EndFunc