Need help

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Sociopathic
Posts: 2
Joined: 22 Jun 2017, 05:18

Need help

22 Jun 2017, 05:22

A friend of mine wrote this code for me as a early birthday present.
It is for a game I have been playing.
Although I am very unfamiliar with autohotkey.
He unfortunately just passed away and I was not able to ask him questions on what to do.
Please help however you can I do not want his hardwork to be useless.



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;#memory.ahk
MemoryOpenFromPID(PID, Privilege=0x1F0FFF)
{
HWND := DllCall("OpenProcess", "Uint", Privilege, "int", 0, "int", PID)
return HWND
}

MemoryOpenFromName(Name, Privilege=0x1F0FFF)
{
Process, Exist, %Name%
PID := ErrorLevel
Return MemoryOpenFromPID(PID, Privilege)
}

MemoryOpenFromTitle(title, privilege=0x1F0FFF)
{
WinGet, PID, PID, %title%
Return MemoryOpenFromPID(PID, Privilege)
}

MemoryClose(hwnd)
{
return DllCall("CloseHandle", "int", hwnd)
}

MemoryWrite(hwnd, address, writevalue, datatype="int", length=4, offset=0)
{
VarSetCapacity(finalvalue, length, 0)
NumPut(writevalue, finalvalue, 0, datatype)
return DllCall("WriteProcessMemory", "Uint", hwnd, "Uint", address+offset, "Uint", &finalvalue, "Uint", length, "Uint", 0)
}

MemoryRead(hwnd, address, datatype="int", length=4, offset=0)
{
VarSetCapacity(readvalue,length, 0)
DllCall("ReadProcessMemory","Uint",hwnd,"Uint",address+offset,"Str",readvalue,"Uint",length,"Uint *",0)
finalvalue := NumGet(readvalue,0,datatype)
return finalvalue
}

MemoryWritePointer(hwnd, base, writevalue, datatype="int", length=4, offsets=0, offset_1=0, offset_2=0, offset_3=0, offset_4=0, offset_5=0, offset_6=0, offset_7=0, offset_8=0, offset_9=0)
{
B_FormatInteger := A_FormatInteger
Loop, %offsets%
{
baseresult := MemoryRead(hwnd,base)
Offset := Offset_%A_Index%
SetFormat, integer, h
base := baseresult + Offset
SetFormat, integer, d
}
SetFormat, Integer, %B_FormatInteger%
return MemoryWrite(hwnd,address,writevalue,datatype,length)
}

MemoryReadPointer(hwnd, base, datatype="int", length=4, offsets=0, offset_1=0, offset_2=0, offset_3=0, offset_4=0, offset_5=0, offset_6=0, offset_7=0, offset_8=0, offset_9=0)
{
B_FormatInteger := A_FormatInteger
Loop, %offsets%
{
baseresult := MemoryRead(hwnd,base)
Offset := Offset_%A_Index%
SetFormat, integer, h
base := baseresult + Offset
SetFormat, integer, d
}
SetFormat, Integer, %B_FormatInteger%
return MemoryRead(hwnd,base,datatyp,length)
}

MemoryGetAddrPID(PID, DllName)
{
VarSetCapacity(me32, 548, 0)
NumPut(548, me32)
snapMod := DllCall("CreateToolhelp32Snapshot", "Uint", 0x00000008, "Uint", PID)
If (snapMod = -1)
Return 0
If (DllCall("Module32First", "Uint", snapMod, "Uint", &me32))
{
Loop
{
If (!DllCall("lstrcmpi", "Str", DllName, "UInt", &me32 + 32)) {
DllCall("CloseHandle", "UInt", snapMod)
Return NumGet(&me32 + 20)
}
}
Until !DllCall("Module32Next", "Uint", snapMod, "UInt", &me32)
}
DllCall("CloseHandle", "Uint", snapMod)
Return 0
}

MemoryGetAddrName(Name, DllName)
{
Process, Exist, %Name%
PID := ErrorLevel
Return MemoryGetAddrPID(PID, DllName)
}

MemoryGetAddrTitle(Title, DllName)
{
WinGet, PID, PID, %Title%
Return MemoryGetAddrPID(PID, DllName)
}

SetPrivilege(privilege = "SeDebugPrivilege")
{
success := DllCall("advapi32.dll\LookupPrivilegeValueA","uint",0,"str",privilege,"int64*",luid_SeDebugPrivilege)
if (success = 1) && (ErrorLevel = 0)
{
returnval = 0
}
else
{
returnval = %ErrorLevel%
}
return %returnval%
}

SuspendProcess(hwnd)
{
return DllCall("ntdll\NtSuspendProcess","uint",hwnd)
}

ResumeProcess(hwnd)
{
return DllCall("ntdll\NtResumeProcess","uint",hwnd)
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;







IF NOT A_IsAdmin
{
Run *RunAs "%A_ScriptFullPath%"
ExitApp
}
SetFormat,float,0
SetKeyDelay , 45, 45s
#SingleInstance force
KeyWait, Delete, D
WinGet, PID, PID, A
WinGet, HWNDToon1, ID, A

hwnd := MemoryOpenFromPID(PID)
pointer := MemoryRead(hwnd, 0x00580B08)






Gui, +AlwaysOnTop

Gui, Add, Text,, Max Life:

Gui, Add, Text,, Current Life:

Gui, Add, Text,, Life Percent:

Gui, Add, Text,, Max Mana:

Gui, Add, Text,, Current Mana:

Gui, Add, Text,, Mana Percent:

Gui, Add, Text,, Exp:


Gui, Add, Edit, ReadOnly vHP_GUI ym

Gui, Add, Edit, ReadOnly vHP_GUI2

Gui, Add, Edit, ReadOnly vHP_GUI3

Gui, Add, Edit, ReadOnly vMA_GUI

Gui, Add, Edit, ReadOnly vMA_GUI2

Gui, Add, Edit, ReadOnly vMA_GUI3

Gui, Add, Edit, ReadOnly vEX_GUI



Gui, Add, Button, x292 y9 w90 h20 gbtn_up, Up
Gui, Add, Button, x212 y29 w90 h20 gbtn_left, Left
Gui, Add, Button, x292 y49 w90 h20 gbtn_down, Down
Gui, Add, Button, x372 y29 w90 h20 gbtn_right, Right

Gui, Add, Button, x302 y119 w100 h20 gbtn_healself, Heal Self
Gui, Add, Button, x302 y140 w100 h20 gbtn_healfighter, Heal Fighter
Gui, Add, Button, x302 y170 w100 h20 gbtn_buffself, Buff Self
Gui, Add, Button, x302 y200 w100 h20 gbtn_HoT, HOT
Gui, Add, Button, x302 y219 w100 h20 gbtn_invoke, Invoke
Gui, Add, Button, x302 y240 w100 h20 gbtn_dmgbuff, DamageBuff
Gui, Add, Button, x302 y260 w100 h20 vbtn_start gbtn_start, DPS ON
Gui, Add, Button, ys x302 y260 w100 h20 vbtn_stop gbtn_stop Disabled, DPS OFF
Gui, Add, Button, x302 y275 w100 h20 gbtn_gate, Gate


Gui, Show, , MornaTK Reader


Loop
{


HP1 := MemoryRead(hwnd, pointer+0x104)
GuiControl,, HP_GUI, %HP1%

HP2 := MemoryRead(hwnd, pointer+0x100)
GuiControl,, HP_GUI2, %HP2%

HP3 := (HP2 / HP1) * 100
GuiControl,, HP_GUI3, %HP3%

MA2 := MemoryRead(hwnd, pointer+0x10c)
GuiControl,, MA_GUI, %MA2%

MA1 := MemoryRead(hwnd, pointer+0x108)
GuiControl,, MA_GUI2, %MA1%

MA3 := (MA1 / MA2) * 100
GuiControl,, MA_GUI3, %MA3%

EX2 := MemoryRead(hwnd, pointer+0x110)
GuiControl,, EX_GUI, %EX2%


}
return







btn_stop:
GuiControl, Disable, btn_stop
IsStoped := True
Return

StopRun:
GuiControl, Enable, btn_start
ToolTip
Return

btn_start:
IsStoped := False
GuiControl, Disable, btn_start
GuiControl, Enable, btn_stop
Goto, LoopRun
Return

LoopRun:
if IsStoped
Goto, StopRun

ControlSend, , {space}, ahk_id %HWNDToon1%
Sleep, 50

; More code ...

Goto, LoopRun
Return


btn_HoT:
F5::
{
ControlSend, , {shift down}z{shift up}d, ahk_id %HWNDToon1%
}
return

btn_HealSelf:
F1::
{
ControlSend, , {shift down}z{shift up}s{home}{enter}, ahk_id %HWNDToon1%
}
Return

btn_HealFighter:
F2::
{
ControlSend, , {tab}{tab}{shift down}z{shift up}s{esc}, ahk_id %HWNDToon1%
}
Return

btn_BuffSelf:
F3::
{
ControlSend, , {shift down}z{shift up}c{home}{enter}, ahk_id %HWNDToon1%
ControlSend, , {tab}{tab}{shift down}z{shift up}c{esc}, ahk_id %HWNDToon1%
ControlSend, , {shift down}z{shift up}g{esc}, ahk_id %HWNDToon1%
}
Return
btn_invoke:
F4::
{
ControlSend, , {shift down}z{shift up}k{esc}, ahk_id %HWNDToon1%
}
Return
btn_Up:
{
ControlSend, , {Up 4}, ahk_id %HWNDToon1%
}
Return

btn_Down:
{
ControlSend, , {Down 4}, ahk_id %HWNDToon1%
}
Return

btn_Left:

{
ControlSend, , {Left 4}, ahk_id %HWNDToon1%
}
Return

btn_Right:
{
ControlSend, , {Right 4}, ahk_id %HWNDToon1%
}
Return

ButtonDoStuff:
{
ControlSend, , {Up 4}, ahk_id %HWNDToon1%
}
return

btn_dmgbuff:
F10::
{
ControlSend, , {shift down}z{shift up}f , ahk_id %HWNDToon1%
}
return

btn_Gate:
F11::
{
ControlSend, , {shift down}z{shift up}an{enter}, ahk_id %HWNDToon1%
}
return
Sociopathic
Posts: 2
Joined: 22 Jun 2017, 05:18

Re: Need help

22 Jun 2017, 05:53

I get the basics (kinda) I can bring of the gui and setup my spells.
But it does not read my Life/Mana/Exp etc.

It seems like there is a way to automate the healing process and what not as well but I am just stuck.

Sorry for my incompetence.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada, Rohwedder and 263 guests