Can AHK handles this?

Ask gaming related questions (AHK v1.1 and older)
redoct2k3
Posts: 1
Joined: 19 Apr 2017, 23:18

Can AHK handles this?

19 Apr 2017, 23:24

See below image - see the green mark on map? I want to click on that spot repeatedly.. The green spot is a character in diablo 2, essentially I want to follow the character. Can AHK ImageSearch do this or should I be searching for color?[img]
spot.png
spot.png (104.49 KiB) Viewed 930 times
[/img]
User avatar
SnowFlake
Posts: 368
Joined: 28 Apr 2015, 05:41
Contact:

Re: Can AHK handles this?

20 Apr 2017, 13:30

the best way to do that is to read the games memory, and then find your X and Y coordinates of the players in the game and then make it fallow it, here is an example:

http://prntscr.com/eytlpk

a good way to test and see the players coordinates with cheat engine is to have 2 diablo open at the same time and then host a game like this,

http://prntscr.com/eytp9l

heres a example of reading the memory of a game (not diablo 2):'

Code: Select all


IF NOT A_IsAdmin
{
   Run *RunAs "%A_ScriptFullPath%"
   ExitApp
}
setSeDebugPrivilege(enable := True)

#SingleInstance Force

ProcessName := "AQ3D.exe"
hwnd := MemoryOpenFromName(ProcessName)


CoordMode, Mouse, Client
CoordMode, Pixel, Client
CoordMode, ToolTip, Client


;///These are Dynamic pointers
Targeted = 0x03CA2BA0 ; IF target a monster then its 1 else its 0
InFight = 0x0D518174 ; IF fighting a monster then its 1 else its 0
Move_Facing_Direction =0x0CDABD70 ;1 moving facing face direction,0 standing still
Direction_Moving =0x0CDABD30
Direction_Moving2 =0x0CDABD64 ;32 = Right |Left = 16|Up  = 1|down = 2|0 = standing still
kills=0 


Gui, Add, Text,vMob w200,No Monsters killed
Gui, Add, Text,vSta w200,--
Gui, Add, Text,vExp w200,0
Gui, Add, Text,vGold w200,0
Gui, Show,h100 w220, AQ3D Hunter

§::

SetTimer,UpdateMemory,1000

SetTimer,RandomMove,7140

WinActivate,ahk_exe AQ3D.exe
WinWaitActive,ahk_exe AQ3D.exe
Sleep, 200
 Home:   
Loop
{ 
 ToolTip, T: %Target% F: %Fighting% Loops:%A_index% ,0,0

Send, {Tab}
GuiControl,,Sta,Looking for Monsters
Sleep, 700
IfEqual,Target,0
{
Times++

IF (Times =6)
{
Times = 0
send, {Left Down}
Sleep, 800
send, {Left Up}
}
 
} 
IfEqual,Target,1
{
GuiControl,,Sta,Monster Found
Sleep, 500

goto,Fight
return

}
}
return

Fight:
Loop
{   
IfEqual,Target,1
{
Random,skill,1,4 
GuiControl,,Sta,Using Skill: %skill%
Send,{%skill%}
Sleep, 2000
}

IfEqual,Target,0
{
 IfEqual,Fighting,0
{ 
 GuiControl,,Sta,Killed a Monster
kills++ 
GuiControl,,Mob,Monsters killed: %kills%
Exps+=11
GuiControl,,Exp,Exp Gained: %Exps%
Golds++
GuiControl,,Gold,Gold Picked: %Golds%
Sleep, 200
gosub, Home
}

}
}
return

RandomMove:

 IfEqual,Fighting,0
{ 
GuiControl,,Sta,Anti Ban
Random, walk, 1,5
SetKeyDelay,100,700
if walk = 1
	send , {right}
else if walk = 2
	send , {left}
else if walk = 3
	send , {up}
else if walk = 4
	send , {down}
else if walk = 5
	send , {Space}

SetKeyDelay,100,50
}
Sleep, 200
return

UpdateMemory:
Target = % MemoryRead(hwnd, Targeted, "int",4)
Fighting = % MemoryRead(hwnd, InFight, "int",4)
 ToolTip, T: %Target% F: %Fighting% Loops:%A_index% ,0,0
return

; ==================================================
; FUCNTIONS!
; ==================================================


MemoryOpenFromName(Name)
{
    Process, Exist, %Name%
    Return DllCall("OpenProcess", "Uint", 0x1F0FFF, "int", 0, "int", PID := ErrorLevel)
}

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)
}

 ; UInt, Int, Int64, Short, UShort, Char, UChar, Double, Float, Ptr or UPtr
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)

if (datatype = "Float")
finalvalue := NumGet(readvalue, 0, "Float")
if (datatype = "Str")
finalvalue := StrGet(&readvalue, length, "UTF-8")
if (datatype = "StrUni")
finalvalue := StrGet(&readvalue, length, "UTF-16")
if NOT (datatype = "Float" or datatype = "Str" or datatype = "StrUni")
{
finalvalue := NumGet(readvalue, 0, datatype)
}
return finalvalue
}

setSeDebugPrivilege(enable := True)
{
    h := DllCall("OpenProcess", "UInt", 0x0400, "Int", false, "UInt", DllCall("GetCurrentProcessId"), "Ptr")
    ; Open an adjustable access token with this process (TOKEN_ADJUST_PRIVILEGES = 32)
    DllCall("Advapi32.dll\OpenProcessToken", "Ptr", h, "UInt", 32, "PtrP", t)
    VarSetCapacity(ti, 16, 0)  ; structure of privileges
    NumPut(1, ti, 0, "UInt")  ; one entry in the privileges array...
    ; Retrieves the locally unique identifier of the debug privilege:
    DllCall("Advapi32.dll\LookupPrivilegeValue", "Ptr", 0, "Str", "SeDebugPrivilege", "Int64P", luid)
    NumPut(luid, ti, 4, "Int64")
    if enable
    	NumPut(2, ti, 12, "UInt")  ; enable this privilege: SE_PRIVILEGE_ENABLED = 2
    ; Update the privileges of this process with the new access token:
    r := DllCall("Advapi32.dll\AdjustTokenPrivileges", "Ptr", t, "Int", false, "Ptr", &ti, "UInt", 0, "Ptr", 0, "Ptr", 0)
    DllCall("CloseHandle", "Ptr", t)  ; close this access token handle to save memory
    DllCall("CloseHandle", "Ptr", h)  ; close this process handle to save memory
    return r
}

^Esc::
ExitApp
return

:yawn:

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 89 guests