Ich benutze die MoveTo Engine von tonitusch666 mit dem dazugehörigen Dumper. Ich habe die Update.ini auf den neuesten Stand gebracht (copy&paste aus
Thread) und selbst mit CE überprüft.Das seltsame ist, das die Funktion CheckArea() aus der tt6.au3 einwandfrei funktioniert! Das heißt die Mems sind OK, jedoch funktioniert dieser simple MoveTo Aufruf nicht:
PHP Code:
#include "tt6.au3"
PrepMoveTo()
MoveTo(1, 14237, -382)
StopMoveTo()
Das einzigste was ich herausgefunden habe und nützlich sein könnte ist Folgendes:
Wenn ich einen Bot (z.B. einer der Test-Bots, die bei der MoveTo Engine mitgeliefert werden) starte, gibt dieser immer die Fehlermeldung "No valid spawnpoint" aus. Das heißt, das meine Mem-Koordinaten des Charakters nicht kongruent mit denen anderer sind. So schlägt deren CheckArea() immer fehl, meins funktioniert jedoch, da ich die Funktion mit meinen "falschen" Koordinaten benutze. Warum meine PosX und PosY Koordinaten jedoch fehlerhaft sein sollten und warum deshalb die MoveTo Funktionen nicht funktionieren sollten weiß ich nicht.
Habe alle relevanten Dateien in den Anhang gepackt. Falls ihr wie ich nicht gerne fremde Dateien runterladet, hier alle im Spoiler:
Update.ini
; update.ini [Gw.exe] - by ddl
; Credits: wadim and Harboe @ ************.com
; Visit:
; 12.3.2010 - 14:37
[SECTION 9-A]
DEATH = 0xa1ad44
Camcourse = 0xa1abe8
AREA_ID = 0xa1bb18
Ping = 0xa158cc
WarningWindow = 0xa29050
FENSTER = 0xa294a0
MemCity = 0xa1bb18
LVL = 0xa181b8
INTERFACE = 0xa16be0
ESC_CLOSE = 0xa17920
LOGIN = 0xa1589c
E-Mail = 0xa156dc
Name = 0xa155b8
DistNrMem = 0xa1754c
MoveBackward = 0xa1b330
PTR_BASEA = 0xa1577c
;Title Offsets:
toffset1 = 0x18
toffset2 = 0x2C
;Titles:
currentKurzick = 0x6e4
currentLuxon = 0x6f4
currentBalthazar = 0x724
currentExp = 0x6dc
MaxKurzick = 0x740
MaxLuxon = 0x744
MaxBalthazar = 0x748
;Title Offset3:
toffset3 = 0x7A4
;Other Titles:
TreasureTitle = 0x70C
LuckyTitle = 0x25C
UnluckyTitle = 0x284
DrunkardTitle = 0x11C
WisdomTitle = 0x734
SunspearTitle = 0x2AC
LightbringerTitle = 0x324
VanguardTitle = 0x644
NornTitle = 0x66C
AsuraTitle = 0x5F4
DeldrimorTitle = 0x61C
PartyTitle = 0x6BC
SweetTitle = 0x554
NorthMastery = 0x694
;Gold Offsets:
goffset1 = 0x18
goffset2 = 0x40
goffset3 = 0xf8
;Gold:
Inventar = 0x7c
Truhe = 0x80
[SECTION D]
POSX = 0xd3ec5c
POSY = 0xd3ec60
CHECK_MAP = 0xd3e8e8
NPC_ID_NEAR = 0xd3e4f8
NPC_ID_SELECT = 0xd3e4d8
SkillsAmAufladen = 0xd406b0
;Agent Info:
AgentArrayPtr = 0xd3e9d8
AgentArrayMaxPtr = 0xd3e9e0
;AgentStruct = AgentArrayPtr + 4 * AgentID
OwnID = 0xd3e984
PTR_HP_E = 0xd3e9a0
;Hp E Offsets:
Offset1 = 0x104
Current_HP = 0x28
Current_E = 0x18
Max_HP = 0x2c
Max_Energie = 0x18
Hero_1_HP = -0xxc
Hero_1_HP = -0x40
Hero_1_HP = -0x74
[Funcs]
ChatSendFunc = 0x7d770f
WhisperFunc = 0x407090
SendFunc = 0x586010
TravelFunc = 0x0
; Credits: wadim and Harboe @ ************.com
; Visit:

; 12.3.2010 - 14:37
[SECTION 9-A]
DEATH = 0xa1ad44
Camcourse = 0xa1abe8
AREA_ID = 0xa1bb18
Ping = 0xa158cc
WarningWindow = 0xa29050
FENSTER = 0xa294a0
MemCity = 0xa1bb18
LVL = 0xa181b8
INTERFACE = 0xa16be0
ESC_CLOSE = 0xa17920
LOGIN = 0xa1589c
E-Mail = 0xa156dc
Name = 0xa155b8
DistNrMem = 0xa1754c
MoveBackward = 0xa1b330
PTR_BASEA = 0xa1577c
;Title Offsets:
toffset1 = 0x18
toffset2 = 0x2C
;Titles:
currentKurzick = 0x6e4
currentLuxon = 0x6f4
currentBalthazar = 0x724
currentExp = 0x6dc
MaxKurzick = 0x740
MaxLuxon = 0x744
MaxBalthazar = 0x748
;Title Offset3:
toffset3 = 0x7A4
;Other Titles:
TreasureTitle = 0x70C
LuckyTitle = 0x25C
UnluckyTitle = 0x284
DrunkardTitle = 0x11C
WisdomTitle = 0x734
SunspearTitle = 0x2AC
LightbringerTitle = 0x324
VanguardTitle = 0x644
NornTitle = 0x66C
AsuraTitle = 0x5F4
DeldrimorTitle = 0x61C
PartyTitle = 0x6BC
SweetTitle = 0x554
NorthMastery = 0x694
;Gold Offsets:
goffset1 = 0x18
goffset2 = 0x40
goffset3 = 0xf8
;Gold:
Inventar = 0x7c
Truhe = 0x80
[SECTION D]
POSX = 0xd3ec5c
POSY = 0xd3ec60
CHECK_MAP = 0xd3e8e8
NPC_ID_NEAR = 0xd3e4f8
NPC_ID_SELECT = 0xd3e4d8
SkillsAmAufladen = 0xd406b0
;Agent Info:
AgentArrayPtr = 0xd3e9d8
AgentArrayMaxPtr = 0xd3e9e0
;AgentStruct = AgentArrayPtr + 4 * AgentID
OwnID = 0xd3e984
PTR_HP_E = 0xd3e9a0
;Hp E Offsets:
Offset1 = 0x104
Current_HP = 0x28
Current_E = 0x18
Max_HP = 0x2c
Max_Energie = 0x18
Hero_1_HP = -0xxc
Hero_1_HP = -0x40
Hero_1_HP = -0x74
[Funcs]
ChatSendFunc = 0x7d770f
WhisperFunc = 0x407090
SendFunc = 0x586010
TravelFunc = 0x0
Test-Programm
#include "tt6.au3"
HotKeySet("{F7}", "Move");
HotKeySet("{F8}", "End");
Func End()
Exit
EndFunc
Func Move()
PrepMoveTo()
MoveTo(1, 14237, -382) ;Koordinaten eines Punktes mittem im Flachland
StopMoveTo()
EndFunc
while(1)
WEnd
HotKeySet("{F7}", "Move");
HotKeySet("{F8}", "End");
Func End()
Exit
EndFunc
Func Move()
PrepMoveTo()
MoveTo(1, 14237, -382) ;Koordinaten eines Punktes mittem im Flachland
StopMoveTo()
EndFunc
while(1)
WEnd
tt6.ini
;
; TT6 movement engine and collection of useful functions
; Rev 1.7
; 15.4.2009
;
; adapt to your screen size and layout !
; note: to debug replace using click function by MouseClick so you can see the position
;
[id]
windowName = Guild Wars
[keys]
; action: follow
FLactkey = ä
; action: do it
DIactkey = SPACE
; target: ally nearest
ANtgtkey = v
; target: foe nearest
FNtgtkey = c
; target: foe next
FXtgtkey = TAB
; target: item nearest
INtgtkey = ö
; target: item next
IXtgtkey = ü
; panel: open guild
OGpnlkey = g
; inventory: toggle all bags
TBinvkey = F9
; movement: automatic run
ARmovkey = r
; movement: reverse direction
RDmovkey = x
; movement: turn left
TLmovkey = a
; movement: turn right
TRmovkey = d
; chat: open chat
OCchtkey = RETURN
[click positions]
; resign/death button
DTclickX = 620
DTclickY = 500
; accept loot
LTclickX = 653
LTclickY = 235
; transfer to gh
GHclickX = 832
GHclickY = 67
; sell tab of trader
STclickX = 495
STclickY = 53
; sell button of trader
SBclickX = 719
SBclickY = 908
; TT6 movement engine and collection of useful functions
; Rev 1.7
; 15.4.2009
;
; adapt to your screen size and layout !
; note: to debug replace using click function by MouseClick so you can see the position
;
[id]
windowName = Guild Wars
[keys]
; action: follow
FLactkey = ä
; action: do it
DIactkey = SPACE
; target: ally nearest
ANtgtkey = v
; target: foe nearest
FNtgtkey = c
; target: foe next
FXtgtkey = TAB
; target: item nearest
INtgtkey = ö
; target: item next
IXtgtkey = ü
; panel: open guild
OGpnlkey = g
; inventory: toggle all bags
TBinvkey = F9
; movement: automatic run
ARmovkey = r
; movement: reverse direction
RDmovkey = x
; movement: turn left
TLmovkey = a
; movement: turn right
TRmovkey = d
; chat: open chat
OCchtkey = RETURN
[click positions]
; resign/death button
DTclickX = 620
DTclickY = 500
; accept loot
LTclickX = 653
LTclickY = 235
; transfer to gh
GHclickX = 832
GHclickY = 67
; sell tab of trader
STclickX = 495
STclickY = 53
; sell button of trader
SBclickX = 719
SBclickY = 908
tt6.au3
;
; TT6 movement engine and collection of functions
; Rev 1.7
; 15.4.2009
;
#include-once
#include <Process.au3>
#include <WindowsConstants.au3>
#include "nomadmemory.au3"
;revision
Const $tt6_rev = "1.7"
;settings
Opt("WinTitleMatchMode", 3)
Opt("MouseCoordMode", 2)
Opt("PixelCoordMode", 2)
#Region Global Variables
; mems compatible to update.ini by __wadim
Const $memx = IniRead("update.ini","SECTION D","POSX","Not found") ; position x
Const $memy = IniRead("update.ini","SECTION D","POSY","Not found") ; position y
Const $memmap = IniRead("update.ini","SECTION D","CHECK_MAP","Not found") ; post=0, load =2, area=1
Const $memnpcidselect = IniRead("update.ini","SECTION D","NPC_ID_SELECT","Not found") ; id of selected object
Const $memnpcidnear = IniRead("update.ini","SECTION D","NPC_ID_NEAR","Not found") ; id of nearest object
Const $memcourse = IniRead("update.ini","SECTION 9-A","CAMCOURSEB","Not found") ; angle of compass/view direction
Const $memdeath = IniRead("update.ini","SECTION 9-A","DEATH","Not found") ; alive = 0 or death = 1
; globals for movement engine
Global $gotox = 0.0, $gotoy = 0.0 , $dist = 0.0, $olddist = 0.0, $angle = 0.0, $increment = 0, $callcnt = 0
Global $client = IniRead("tt6.ini","id","windowName","Guild Wars")
$PID = WinGetProcess($client)
Global $hprocess = _MemoryOpen($PID)
Global $hwnd = WinGetHandle($client)
Global $running = False, $stopCheck = False, $blockCheck = False
Const $pi = 4 * ATan(1)
Global $accelmul = 1.0 ;modify to accelerate or slow down control action
Global $isDead = False ;global status to check if got killed, set to False after recovery or new movement
Global $gotBlocked = False ;global status to check if got blocked, set to False after exception handling
Global $noLoot = False ;global status to temporarily disable looting e.g. in parallel adlib thread
;debug movement
Const $debug_pos = False ;set True to show current movement segment
Const $debug_mov = False ;set True to show left/right control action
; keys for keyboard input simulation adapt in the tt6.ini
Const $DIactkey = IniRead("tt6.ini","keys","DIactkey","SPACE")
Const $FLactkey = IniRead("tt6.ini","keys","FLactkey","ä")
Const $ANtgtkey = IniRead("tt6.ini","keys","ANtgtkey","v")
Const $FNtgtkey = IniRead("tt6.ini","keys","FNtgtkey","c")
Const $FXtgtkey = IniRead("tt6.ini","keys","FXtgtkey","TAB")
Const $INtgtkey = IniRead("tt6.ini","keys","INtgtkey","ö")
Const $IXtgtkey = IniRead("tt6.ini","keys","IXtgtkey","ü")
Const $OGpnlkey = IniRead("tt6.ini","keys","OGpnlkey","g")
Const $TBinvkey = IniRead("tt6.ini","keys","TBinvkey","F9")
Const $ARmovkey = IniRead("tt6.ini","keys","ARmovkey","r")
Const $RDmovkey = IniRead("tt6.ini","keys","RDmovkey","x")
Const $TLmovkey = IniRead("tt6.ini","keys","TLmovkey","a")
Const $TRmovkey = IniRead("tt6.ini","keys","TRmovkey","d")
Const $OCchtkey = IniRead("tt6.ini","keys","OCchtkey","RETURN")
; positions for mouse clicks adapt in the tt6.ini
Const $DTclickX = Int(IniRead("tt6.ini","click positions","DTclickX",0))
Const $DTclickY = Int(IniRead("tt6.ini","click positions","DTclickY",0))
Const $LTclickX = Int(IniRead("tt6.ini","click positions","LTclickX",0))
Const $LTclickY = Int(IniRead("tt6.ini","click positions","LTclickY",0))
Const $GHclickX = Int(IniRead("tt6.ini","click positions","GHclickX",0))
Const $GHclickY = Int(IniRead("tt6.ini","click positions","GHclickY",0))
Const $STclickX = Int(IniRead("tt6.ini","click positions","STclickX",0))
Const $STclickY = Int(IniRead("tt6.ini","click positions","STclickY",0))
Const $SBclickX = Int(IniRead("tt6.ini","click positions","SBclickX",0))
Const $SBclickY = Int(IniRead("tt6.ini","click positions","SBclickY",0))
Const $HMclickX = Int(IniRead("tt6.ini","click positions","HMclickX",0))
Const $HMclickY = Int(IniRead("tt6.ini","click positions","HMclickY",0))
;generate inventory access matrix adapt positions in the tt6.ini
Const $invMaxR = 8 ;max number of rows 0..8
Const $invMaxC = 4 ;max number of columns 0..4
Global $invPos[$invMaxC+1] [$invMaxR+1][2];matrix of positions [0]=x, [1]=y
$invPos[0][0][0] = Int(IniRead("tt6.ini","inventory offsets","invPosX00",0))
$invPos[0][0][1] = Int(IniRead("tt6.ini","inventory offsets","invPosY00",0))
$invPos[0][1][1] = Int(IniRead("tt6.ini","inventory offsets","invPosYR1",0))
$invPos[0][2][1] = Int(IniRead("tt6.ini","inventory offsets","invPosYR2",0))
$invPos[0][3][1] = Int(IniRead("tt6.ini","inventory offsets","invPosYR3",0))
$invPos[0][4][1] = Int(IniRead("tt6.ini","inventory offsets","invPosYR4",0))
$invPos[0][5][1] = Int(IniRead("tt6.ini","inventory offsets","invPosYR5",0))
$invPos[0][6][1] = Int(IniRead("tt6.ini","inventory offsets","invPosYR6",0))
$invPos[0][7][1] = Int(IniRead("tt6.ini","inventory offsets","invPosYR7",0))
$invPos[0][8][1] = Int(IniRead("tt6.ini","inventory offsets","invPosYR8",0))
$invPosXdelta = Int(IniRead("tt6.ini","inventory offsets","invPosXdelta",0))
For $ri=1 To 8
$invPos[0][$ri][0] = $invPos[0][0][0] ;x offset of 0 element constant in every row
Next
For $ri=0 To 8
For $ci=1 To 4
$invPos[$ci][$ri][0] = $invPos[0][$ri][0] + $invPosXdelta *$ci ; x offset increases by number of column
$invPos[$ci][$ri][1] = $invPos[0][$ri][1] ; y offset equal to 0 position in every row
Next
Next
;blacklist for CollectLoot
;position 0 contains number of valid entries
Const $CLBlackMax = 50
Global $CLBlackList[$CLBlackMax +1]
$CLBlackList[0] = 0
#EndRegion
#Region Movement Engine
; stop movement
Func StopMoveTo()
if Not $gotBlocked Then
KeySend($ARmovkey)
EndIf
$increment = 0
$callcnt = 0
$running = False
$stopCheck = False
$blockCheck = False
EndFunc
; end movement but keep running e.g. to exit
Func KeepMoveTo()
$increment = 0
$callcnt = 0
$running = False
$stopCheck = False
$blockCheck = False
EndFunc
; prepare movement
Func PrepMoveTo()
$increment = 0
$callcnt = 0
$stopCheck = False
$blockCheck = False
$gotBlocked = False
EndFunc
; disables check if we stopped runnning unintended (eg by cast or knock down)
; note: must be used to protect casts as we try to start running again immediately in auto mode
Func DisableStopCheck()
if $stopCheck Then
$stopCheck = False
EndIf
EndFunc
; enables check again
Func EnableStopCheck()
if ($blockCheck = False) And ($stopCheck = False) Then
$stopCheck = True
EndIf
EndFunc
; calc table for rotation angle calculation
Global $course_table[100]
$course_table[0] = 0.0000
$course_table[1] = 0.0000
$course_table[2] = 0.0000
$course_table[3] = 0.0438
$course_table[4] = 0.0702
$course_table[5] = 0.1031
$course_table[6] = 0.1377
$course_table[7] = 0.1466
$course_table[8] = 0.1751
$course_table[9] = 0.1824
$course_table[10] = 0.2076
$course_table[11] = 0.2462
$course_table[12] = 0.2551
$course_table[13] = 0.2750
$course_table[14] = 0.3154
$course_table[15] = 0.3337
$course_table[16] = 0.3528
$course_table[17] = 0.3612
$course_table[18] = 0.3800
$course_table[19] = 0.4078
$course_table[20] = 0.4273
$course_table[21] = 0.4458
$course_table[22] = 0.4670
$course_table[23] = 0.4845
$course_table[24] = 0.5120
$course_table[25] = 0.5361
$course_table[26] = 0.5656
$course_table[27] = 0.5936
$course_table[28] = 0.6285
$course_table[29] = 0.6445
$course_table[30] = 0.6643
$course_table[31] = 0.6848
$course_table[32] = 0.6991
$course_table[33] = 0.7136
$course_table[34] = 0.7214
$course_table[35] = 0.7452
$course_table[36] = 0.7746
$course_table[37] = 0.8052
$course_table[38] = 0.8283
$course_table[39] = 0.8410
$course_table[40] = 0.8666
$course_table[41] = 0.8826
$course_table[42] = 0.9062
$course_table[43] = 0.9195
$course_table[44] = 0.9363
$course_table[45] = 0.9531
$course_table[46] = 0.9759
$course_table[47] = 1.0020
$course_table[48] = 1.0203
$course_table[49] = 1.0448
$course_table[50] = 1.0636
$course_table[51] = 1.0882
$course_table[52] = 1.0957
$course_table[53] = 1.1124
$course_table[54] = 1.1474
$course_table[55] = 1.1669
$course_table[56] = 1.1833
$course_table[57] = 1.2264
$course_table[58] = 1.2469
$course_table[59] = 1.2670
$course_table[60] = 1.2876
$course_table[61] = 1.2957
$course_table[62] = 1.3056
$course_table[63] = 1.3331
$course_table[64] = 1.3529
$course_table[65] = 1.3769
$course_table[66] = 1.3975
$course_table[67] = 1.4162
$course_table[68] = 1.4366
$course_table[69] = 1.4684
$course_table[70] = 1.4844
$course_table[71] = 1.5089
$course_table[72] = 1.5223
$course_table[73] = 1.5420
$course_table[74] = 1.5721
$course_table[75] = 1.5994
$course_table[76] = 1.6089
$course_table[77] = 1.6203
$course_table[78] = 1.6485
$course_table[79] = 1.6632
$course_table[80] = 1.6791
$course_table[81] = 1.6807
$course_table[82] = 1.7258
$course_table[83] = 1.7630
$course_table[84] = 1.7801
$course_table[85] = 1.8172
$course_table[86] = 1.8256
$course_table[87] = 1.8400
$course_table[88] = 1.8654
$course_table[89] = 1.8804
$course_table[90] = 1.9119
$course_table[91] = 1.9391
$course_table[92] = 1.9605
$course_table[93] = 1.9822
$course_table[94] = 2.0091
$course_table[95] = 2.0203
$course_table[96] = 2.0433
$course_table[97] = 2.0654
$course_table[98] = 2.0749
$course_table[99] = 2*$pi
; calculate rotation angle
Func GetCourse($val)
$i=0
$valL = Abs($val)
While $course_table[$i] < $valL
$i +=1
if $i = 100 Then ;error
ConsoleWrite(StringFormat("GetCourse: bad call: %.4f",$valL))
Exit
EndIf
WEnd
return Int($i * 10 * $accelmul)
EndFunc
; initialise new destination
Func InitDest($dx, $dy, $dcheck = False)
;no movement if we are dead or got blocked
If $isDead Or $gotBlocked Then
Return
EndIf
; set global destination
$gotox = $dx
$gotoy = $dy
if $debug_pos Then
ConsoleWrite(StringFormat("InitDest: %d %d\n",$gotox, $gotoy))
EndIf
; calc distance
$posx = _memoryread($memx,$hprocess,'float')
$posy = _memoryread($memy,$hprocess,'float')
$dist = Sqrt(($posx-$gotox)^2 + ($posy-$gotoy)^2)
$olddist = $dist
;set call counter for cyclic loop
$callcnt = 1
; set stop level for angles in relation to distance
if $dist > 2000 Then
$stoplvl = 1.8
Elseif $dist > 1200 Then
$stoplvl = 1.5
Elseif $dist > 700 Then
$stoplvl = 1.2
Elseif $dist > 400 Then
$stoplvl = 0.8
Elseif $dist > 200 Then
$stoplvl = 0.6
Else
$stoplvl = 0.2
EndIf
; calc angle
$angle = ACos(($gotox - $posx)/$dist)
if $gotoy < $posy Then
$angle = -$angle
EndIf
; rotate view to destination
$cnt =0
Do
; transition via q2<->q3 by pseudo course angle
$curcou = _memoryread($memcourse,$hprocess,'float')
if (($angle > $pi/2) And ($curcou < $angle - $pi)) Then
$curcou = 2*$pi + $curcou
EndIf
if (($angle < -$pi/2) And ($curcou > $pi+$angle)) Then
$curcou = -2*$pi + $curcou
EndIf
; big delta -> stop running
if Abs($angle - $curcou) > $stoplvl Then
if $running = True Then
KeySend($ARmovkey)
$running = False
EndIf
EndIf
$accel = GetCourse(Abs($angle - $curcou))
; rotate
if $angle < $curcou Then
KeySend($TRmovkey, "down")
Sleep($accel)
KeySend($TRmovkey, "up")
if $debug_mov = True Then
ConsoleWrite(StringFormat("InitDest: %s %d %.4f %.0f\n",$TRmovkey ,$accel, $angle, $dist))
EndIf
Else
KeySend($TLmovkey, "down")
Sleep($accel)
KeySend($TLmovkey, "up")
if $debug_mov = True Then
ConsoleWrite(StringFormat("InitDest: %s %d %.4f %.0f\n",$TLmovkey ,$accel, $angle, $dist))
EndIf
EndIf
Sleep(100)
$cnt +=1
; check for death
if $dcheck And _memoryread($memdeath,$hprocess) = 1 Then
$isDead = True
Return
EndIf
; sometimes GW does not accept rotation keys, so just start movement and proceed with fingers crossed
Until (Abs($angle - $curcou) <0.1) Or ($cnt > 10)
EndFunc
; cyclic function for movement to destination (must be called every 10ms)
Func MoveToCore($okdist, $dcheck = False)
;no movement if we are dead or got blocked
If $isDead Or $gotBlocked Then
Return True
EndIf
; get data
$posx = _memoryread($memx,$hprocess,'float')
$posy = _memoryread($memy,$hprocess,'float')
$curcou = _memoryread($memcourse,$hprocess,'float')
; calc distance
$dist = Sqrt(($posx-$gotox)^2 + ($posy-$gotoy)^2)
; try to catch problem in case we missed target
if $olddist < $dist -100.0 Then
InitDest($gotox, $gotoy, $dcheck)
EndIf
; store distance every 500ms, initial value is set in InitDest(), check for special situations
If Mod($callcnt, 50) = 0 Then
; set death flag and exit
if $dcheck And _memoryread($memdeath,$hprocess) = 1 Then
$isDead = True
Return True
EndIf
; restart running in case we got stopped
if $stopCheck And (Abs($olddist - $dist) < 20.0) Then
$running = False
EndIf
; set blocked flag and exit
if $blockCheck And (Abs($olddist - $dist) < 20.0) Then
$gotBlocked = True
Return True
EndIf
$olddist = $dist
EndIf
;increment call counter
$callcnt +=1
; check running
if $running = False Then
$running = True
KeySend($ARmovkey)
EndIf
; calc angle
$angle = ACos(($gotox - $posx)/$dist)
if $gotoy < $posy Then
$angle = -$angle
EndIf
; correct angle on the fly
If (Abs($angle - $curcou) >0.1) And ($increment = 0) Then
; transition via q2<->q3 by pseudo course angle
$curcou = _memoryread($memcourse,$hprocess,'float')
if (($angle > $pi/2) And ($curcou < $angle - $pi)) Then
$curcou = 2*$pi + $curcou
EndIf
if (($angle < -$pi/2) And ($curcou > $pi+$angle)) Then
$curcou = -2*$pi + $curcou
EndIf
$increment = GetCourse(Abs($angle - $curcou))
; rotate
if $angle < $curcou Then
KeySend($TRmovkey, "down")
$increment -=10
if $debug_mov = True Then
ConsoleWrite(StringFormat("MoveToCore: %s %d %.4f %.0f\n",$TRmovkey ,$increment, $angle, $dist))
EndIf
Else
KeySend($TLmovkey, "down")
$increment -=10
if $debug_mov = True Then
ConsoleWrite(StringFormat("MoveToCore: %s %d %.4f %.0f\n",$TLmovkey ,$increment, $angle, $dist))
EndIf
EndIf
ElseIf ($increment > 0) Then
$increment -=10
if $increment <= 0 Then
KeySend($TRmovkey, "up")
KeySend($TLmovkey, "up")
EndIf
EndIf
; reached position
If $dist < $okdist Then
$increment = 0
KeySend($TRmovkey, "up")
KeySend($TLmovkey, "up")
if $debug_pos Then
ConsoleWrite(StringFormat("MoveToCore: %d %d\n",$gotox, $gotoy))
EndIf
return True
EndIf
Return False
EndFunc
; movement function
; $mode = 0 : do one iteration and return, used in very special situations only
; $mode = 1 : init destination and move there
; $mode = 2 : autorun mode, if a stop is detected it will be tried to run again automatically
; $mode = 3 : block mode, if a block is detected we set flag and exit
; $random adds some variation to movement positions
; $dcheck enables deathcheck
; $okdist specifies the distance to the destination which will be accepted as position reached
Func MoveTo($mode, $x, $y, $random = False, $dcheck = False, $okdist = 130.0)
$xl = $x
$yl = $y
if $random Then
$xl = $x + Int(Random(-100,100))
$yl = $y + Int(Random(-100,100))
EndIf
if $mode = 0 Then
$stopCheck = False
$blockCheck = False
Return MoveToCore($okdist, $dcheck)
ElseIf $mode = 1 Then
$stopCheck = False
$blockCheck = False
InitDest($xl, $yl, $dcheck)
While Not MoveToCore($okdist, $dcheck)
Sleep(10)
WEnd
ElseIf $mode = 2 Then
$stopCheck = True
$blockCheck = False
InitDest($xl, $yl, $dcheck)
While Not MoveToCore($okdist, $dcheck)
Sleep(10)
WEnd
ElseIf $mode = 3 Then
$stopCheck = False
$blockCheck = True
InitDest($xl, $yl, $dcheck)
While Not MoveToCore($okdist, $dcheck)
Sleep(10)
WEnd
Else ;error
ConsoleWrite(StringFormat("MoveTo: bad mode: %d",$mode))
Exit
EndIf
EndFunc
#EndRegion
#Region Collection of Functions
; check if position is in area
Func CheckArea($xval, $yval)
$ret = False
$pX = _memoryread($memx,$hprocess,'float')
$pY = _memoryread($memy,$hprocess,'float')
if ($pX < $xval + 250) And ($pX > $xval - 250) And ($pY < $yval + 250) And ($pY > $yval - 250) Then
$ret = True
EndIf
Return $ret
EndFunc
; random sleep function with -+5% variation
Func RndSleep($val)
$sle = Random($val * 0.95, $val *1.05, 1)
Sleep($sle)
EndFunc
;check if we got killed
Func CheckDeath()
if _memoryread($memdeath,$hprocess) = 1 Then
$isDead = true
return true
EndIf
EndFunc
;enable hardmode
func EnableHM()
MouseSend("left", "click", $HMclickX, $HMclickY)
EndFunc
; check area for not collectable items like chests/signs etc.
Func BuildCLBlackList()
$CLBlackList[0] = 0
KeySend($INtgtkey)
Sleep(200)
$cnt = 0
$id = _memoryread($memnpcidselect,$hprocess)
While ( $id > 0 And $cnt < $CLBlackMax)
for $i=1 to $cnt
If $CLBlacklist[$i] = $id Then ExitLoop 2
Next
$cnt +=1
$CLBlackList[$cnt] = $id
KeySend($IXtgtkey)
Sleep(200)
$id = _memoryread($memnpcidselect,$hprocess)
WEnd
$CLBlackList[0] = $cnt
EndFunc
; collect loot
; $max limits number of items to pick up
; $checkblack enables usage of blacklist generated by a call to BuildCLBlackList()
; $retrytime specifies the time in ms to do another attempt to collect the item,
; useful if items may be spread all over the place after a farm run
; $retrycount specifies how many retry attempts should be done until item gets blacklisted
; (e.g. blocked by an foe)
Func CollectLoot($max, $checkblack = False, $retrytime = 200, $retrycount = 0)
$cnt =0
If $checkblack Then
$max += $CLBlackList[0]
Else
; clear old blacklist
$CLBlackList[0] =0
EndIf
;select first item
KeySend($INtgtkey)
RndSleep(200)
$id = _memoryread($memnpcidselect,$hprocess)
While ( $id > 0) And ($cnt < $max)
;check for death
If (_memoryread($memdeath,$hprocess) = 1) Then ExitLoop
;check if item has been blacklisted
If $checkblack Then
For $i = 1 To $CLBlackList[0]
If $CLBlackList[$i] = $id Then
KeySend($IXtgtkey)
RndSleep(200)
$id = _memoryread($memnpcidselect,$hprocess)
$cnt +=1
ContinueLoop 2
EndIf
Next
EndIf
;check if looting has been disabled
$CLtimer = TimerInit()
While $noLoot
$CLtime = TimerDiff($CLtimer)
Sleep(500)
If $CLtime > 30000 Then ;noLoot timeout
ConsoleWrite("CollectLoot: noLoot timeout exceeded")
Exit
EndIf
WEnd
;collect item
$rcnt = 0
KeySend($DIactkey)
RndSleep(200)
$CLtimer = TimerInit()
While ($id = _memoryread($memnpcidselect,$hprocess))
Sleep(100)
;wait if we have to run a longer distance
$CLtime = TimerDiff($CLtimer)
if $CLtime > $retrytime Then
;dont do a retry just wait retrytime
if $retrycount = 0 Then ExitLoop
;try again
KeySend($DIactkey)
$rcnt +=1
;max retries reached, check if still not collected and blacklist item
if $rcnt = $retrycount Then
RndSleep(200)
If ($id = _memoryread($memnpcidselect,$hprocess)) Then
$checkblack = True
$enter = True
for $i=1 to $CLBlackList[0]
If $CLBlacklist[$i] = $id Then
$enter = False
EndIf
Next
if $enter Then
$CLBlackList[0] +=1
$CLBlackList[$CLBlackList[0]] = $id
EndIf
EndIf
ExitLoop
EndIf
$CLtimer = TimerInit()
EndIf
;check for death
If (_memoryread($memdeath,$hprocess) = 1) Then ExitLoop 2
WEnd
;select next item
KeySend($INtgtkey)
RndSleep(200)
$id = _memoryread($memnpcidselect,$hprocess)
$cnt +=1
WEnd
EndFunc
; resign
Func Resign($wdelay = 50)
$cnt = 0
Do
keysend("-")
Sleep($wdelay)
keysend("r")
Sleep($wdelay)
keysend("e")
Sleep($wdelay)
keysend("s")
Sleep($wdelay)
keysend("i")
Sleep($wdelay)
keysend("g")
Sleep($wdelay)
keysend("n")
Sleep($wdelay)
keysend("RETURN")
RndSleep(5500)
$cnt +=1
Until (_memoryread($memdeath,$hprocess) = 1) Or $cnt >3
ControlClick($client, "", "", "left", 1, $DTclickX, $DTclickY)
EndFunc
; wait until dead and got rezzed
Func WaitRezz()
While _memoryread($memdeath,$hprocess) <> 1
Sleep(2000)
WEnd
While _memoryread($memdeath,$hprocess) <> 0
Sleep(2000)
WEnd
RndSleep(3000)
EndFunc
; transfer to different area / portal
; $toID specifies area we want to travel to
; $timeout is the time in sec after we exit with an error
Func TransferArea($toID, $timeout = 20)
; wait until transfer has started
$cnt = 0
While Not ((_memoryread($memmap,$hprocess)) = 2)
Sleep(200)
$cnt +=1
if $cnt > 5*$timeout Then
ConsoleWrite("TransferArea: transfer timeout exceeded")
Exit
EndIf
WEnd
;wait until new area has been reached
$cnt = 0
While (_memoryread($memmap,$hprocess)) <> $toID
Sleep(200)
$cnt +=1
if $cnt > 5*$timeout Then
ConsoleWrite(StringFormat("TransferArea: area ID: %d timeout exceeded", $toID))
Exit
EndIf
WEnd
RndSleep(4000)
;wait until course has been stabilized
$cnt = 0
While _memoryread($memcourse,$hprocess,'float') > 2*$pi
Sleep(200)
$cnt +=1
if $cnt > 5*$timeout Then
ConsoleWrite("TransferArea: course timeout exceeded")
Exit
EndIf
WEnd
EndFunc
; transfer to GH, may be used from/to GH
Func TransferGH()
KeySend($OGpnlkey)
RndSleep(500)
ControlClick($client, "", "", "left", 1, $GHclickX, $GHclickY)
$cnt = 0
While Not ((_memoryread($memmap,$hprocess)) = 2)
Sleep(200)
$cnt +=1
if Mod($cnt, 10) = 0 Then
ControlClick($client, "", "", "left", 1, $GHclickX, $GHclickY)
EndIf
if Mod($cnt, 15) = 0 Then
KeySend($OGpnlkey)
EndIf
WEnd
While (_memoryread($memmap,$hprocess)) <> 0
Sleep(100)
WEnd
RndSleep(4000)
KeySend($OGpnlkey)
RndSleep(500)
EndFunc
; ident all items from start row to end row (0..8) using ident kit at row/col (0..4)
Func IdentItems($StartRow, $EndRow, $IdentCol, $IdentRow)
KeySend($TBinvkey)
RndSleep(500)
if $EndRow > $invMaxR Then
$end = $invMaxR
Else
$end = $EndRow
EndIf
For $row = $StartRow To $end
For $col = 0 To $invMaxC
MouseSend("left", "dclick", $invPos[$IdentCol][$IdentRow][0], $invPos[$IdentCol][$IdentRow][1])
RndSleep(250)
MouseSend("left", "click", $invPos[$col][$row][0], $invPos[$col][$row][1])
RndSleep(250)
Next
Next
RndSleep(500)
KeySend($TBinvkey)
EndFunc
;Sell items at trader
func SellatTrader($countclicks)
KeySend($ANtgtkey)
RndSleep(500)
KeySend($DIactkey)
RndSleep(2000)
MouseSend("left", "click", $STclickX, $STclickY)
RndSleep(200)
for $i = 1 to $countclicks
MouseSend("left", "click", $SBclickX, $SBclickY)
RndSleep(200)
Next
EndFunc
#EndRegion
#Region Helper Functions
; create long int (32 bit) from 2 short int (16 bit)
Func MakeLong($LoWord, $HiWord)
Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF))
EndFunc
; send mouse events to non active window
; button = left, right, none
; event = down, up, click, dclick, move
Func MouseSend($btn, $evt, $xpos, $ypos)
$user32 = DllOpen("user32.dll")
if $user32 = -1 Then
ConsoleWrite("MouseSend: cannot open user32.dll")
Exit
EndIf
;define missing constans
$MK_LBUTTON = 0x0001
$WM_LBUTTONDOWN = 0x0201
;$WM_LBUTTONUP = 0x0202 -> defined in WindowsConstants.au3
$WM_LBUTTONDBLCLK = 0x0203
$MK_RBUTTON = 0x0002
$WM_RBUTTONDOWN = 0x0204
$WM_RBUTTONUP = 0x0205
$WM_RBUTTONDBLCLK = 0x0206
;$WM_MOUSEMOVE = 0x0200 -> defined in WindowsConstants.au3
;map button to event
If $btn = "left" Then
$button = $MK_LBUTTON
$btdown = $WM_LBUTTONDOWN
$btup = $WM_LBUTTONUP
$btdbl = $WM_LBUTTONDBLCLK
ElseIf $btn = "right" Then
$button = $MK_RBUTTON
$btdown = $WM_RBUTTONDOWN
$btup = $WM_RBUTTONUP
$btdbl = $WM_RBUTTONDBLCLK
ElseIf $btn = "none" Then
If Not ($evt = "move") Then
ConsoleWrite(StringFormat("MouseSend: bad call: %s , %s",$btn, $evt))
Exit
EndIf
Else ;error
ConsoleWrite(StringFormat("MouseSend: bad button: %s",$btn))
Exit
EndIf
;send messages
$pos = MakeLong($xpos, $ypos)
Select
Case $evt = "move"
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_MOUSEMOVE, "int", 0, "long", $pos)
Case $evt = "down"
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $btdown, "int", $button, "long", $pos)
Case $evt = "up"
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $btup, "int", 0, "long", $pos)
Case $evt = "click"
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_MOUSEMOVE, "int", 0, "long", $pos)
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $btdown, "int", $button, "long", $pos)
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $btup, "int", 0, "long", $pos)
Case $evt = "dclick"
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_MOUSEMOVE, "int", 0, "long", $pos)
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $btdown, "int", $button, "long", $pos)
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $btup, "int", 0, "long", $pos)
Sleep(10)
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $btdbl, "int", $button, "long", $pos)
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $btup, "int", 0, "long", $pos)
EndSelect
DllClose($user32)
EndFunc
; send single keyboard event to non active window
; event = pressed, down, up
; kdown = key down delay
; note: supports only lower case keys + NUMx, Fx, some special keys and @
Func KeySend($inkey, $evt ="pressed", $kdown = 50)
$user32 = DllOpen("user32.dll")
if $user32 = -1 Then
ConsoleWrite("KeySend: cannot open user32.dll")
Exit
EndIf
; handling for special keys
Switch StringUpper($inkey)
Case "@"
$skey = 0x40
$lparam = 0x00100001
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_KEYDOWN, "int", 0x71, "long", $lparam)
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_CHAR, "int", $skey, "long", $lparam)
Sleep(20)
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_KEYUP, "int", 0x71, "long", BitOR($lparam, 0xC0000000))
Case "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12"
$skey = 0x6f + Int(StringMid($inkey, 2))
ContinueCase
Case "NUM0", "NUM1", "NUM2", "NUM3", "NUM4", "NUM5", "NUM6", "NUM7", "NUM8" , "NUM9"
if StringUpper(StringLeft($inkey, 3)) = "NUM" Then
$skey = 0x60 + Int(StringMid($inkey, 4))
EndIf
ContinueCase
Case "RETURN", "SPACE", "TAB", "BACK", "END", "HOME", "SNAPSHOT", "INSERT", "DELETE", "LEFT", "RIGHT", "UP", "DOWN"
Switch StringUpper($inkey)
Case "RETURN"
$skey = 0x0D
Case "SPACE"
$skey = 0x20
Case "TAB"
$skey = 0x09
Case "BACK"
$skey = 0x08
Case "END"
$skey = 0x23
Case "HOME"
$skey = 0x24
Case "SNAPSHOT"
$skey = 0x2c
Case "INSERT"
$skey = 0x2d
Case "DELETE"
$skey = 0x2e
Case "LEFT"
$skey = 0x25
Case "RIGHT"
$skey = 0x27
Case "UP"
$skey = 0x26
Case "DOWN"
$skey = 0x28
EndSwitch
$ret = DllCall($user32, "int", "MapVirtualKey", "int", $skey, "int", 0)
$lparam = BitShift($ret[0], -16)
$lparam = BitOr($lparam, 1)
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_KEYDOWN, "int", $skey, "long", $lparam)
Sleep($kdown)
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_KEYUP, "int", $skey, "long", BitOR($lparam, 0xC0000000))
Case Else ; default lower case key handling
$key = DllCall($user32, "int", "VkKeyScan", "int", Asc(StringLower($inkey)))
$skey = $key[0]
$ret = DllCall($user32, "int", "MapVirtualKey", "int", $skey, "int", 0)
$lparam = BitShift($ret[0], -16)
$lparam = BitOr($lparam, 1)
Select
Case $evt = "pressed"
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_KEYDOWN, "int", $skey, "long", $lparam)
Sleep($kdown)
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_KEYUP, "int", $skey, "long", BitOR($lparam, 0xC0000000))
Case $evt = "down"
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_KEYDOWN, "int", $skey, "long", $lparam)
Case $evt = "up"
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_KEYUP, "int", $skey, "long", BitOR($lparam, 0xC0000000))
EndSelect
EndSwitch
DllClose($user32)
EndFunc
#EndRegion
; TT6 movement engine and collection of functions
; Rev 1.7
; 15.4.2009
;
#include-once
#include <Process.au3>
#include <WindowsConstants.au3>
#include "nomadmemory.au3"
;revision
Const $tt6_rev = "1.7"
;settings
Opt("WinTitleMatchMode", 3)
Opt("MouseCoordMode", 2)
Opt("PixelCoordMode", 2)
#Region Global Variables
; mems compatible to update.ini by __wadim
Const $memx = IniRead("update.ini","SECTION D","POSX","Not found") ; position x
Const $memy = IniRead("update.ini","SECTION D","POSY","Not found") ; position y
Const $memmap = IniRead("update.ini","SECTION D","CHECK_MAP","Not found") ; post=0, load =2, area=1
Const $memnpcidselect = IniRead("update.ini","SECTION D","NPC_ID_SELECT","Not found") ; id of selected object
Const $memnpcidnear = IniRead("update.ini","SECTION D","NPC_ID_NEAR","Not found") ; id of nearest object
Const $memcourse = IniRead("update.ini","SECTION 9-A","CAMCOURSEB","Not found") ; angle of compass/view direction
Const $memdeath = IniRead("update.ini","SECTION 9-A","DEATH","Not found") ; alive = 0 or death = 1
; globals for movement engine
Global $gotox = 0.0, $gotoy = 0.0 , $dist = 0.0, $olddist = 0.0, $angle = 0.0, $increment = 0, $callcnt = 0
Global $client = IniRead("tt6.ini","id","windowName","Guild Wars")
$PID = WinGetProcess($client)
Global $hprocess = _MemoryOpen($PID)
Global $hwnd = WinGetHandle($client)
Global $running = False, $stopCheck = False, $blockCheck = False
Const $pi = 4 * ATan(1)
Global $accelmul = 1.0 ;modify to accelerate or slow down control action
Global $isDead = False ;global status to check if got killed, set to False after recovery or new movement
Global $gotBlocked = False ;global status to check if got blocked, set to False after exception handling
Global $noLoot = False ;global status to temporarily disable looting e.g. in parallel adlib thread
;debug movement
Const $debug_pos = False ;set True to show current movement segment
Const $debug_mov = False ;set True to show left/right control action
; keys for keyboard input simulation adapt in the tt6.ini
Const $DIactkey = IniRead("tt6.ini","keys","DIactkey","SPACE")
Const $FLactkey = IniRead("tt6.ini","keys","FLactkey","ä")
Const $ANtgtkey = IniRead("tt6.ini","keys","ANtgtkey","v")
Const $FNtgtkey = IniRead("tt6.ini","keys","FNtgtkey","c")
Const $FXtgtkey = IniRead("tt6.ini","keys","FXtgtkey","TAB")
Const $INtgtkey = IniRead("tt6.ini","keys","INtgtkey","ö")
Const $IXtgtkey = IniRead("tt6.ini","keys","IXtgtkey","ü")
Const $OGpnlkey = IniRead("tt6.ini","keys","OGpnlkey","g")
Const $TBinvkey = IniRead("tt6.ini","keys","TBinvkey","F9")
Const $ARmovkey = IniRead("tt6.ini","keys","ARmovkey","r")
Const $RDmovkey = IniRead("tt6.ini","keys","RDmovkey","x")
Const $TLmovkey = IniRead("tt6.ini","keys","TLmovkey","a")
Const $TRmovkey = IniRead("tt6.ini","keys","TRmovkey","d")
Const $OCchtkey = IniRead("tt6.ini","keys","OCchtkey","RETURN")
; positions for mouse clicks adapt in the tt6.ini
Const $DTclickX = Int(IniRead("tt6.ini","click positions","DTclickX",0))
Const $DTclickY = Int(IniRead("tt6.ini","click positions","DTclickY",0))
Const $LTclickX = Int(IniRead("tt6.ini","click positions","LTclickX",0))
Const $LTclickY = Int(IniRead("tt6.ini","click positions","LTclickY",0))
Const $GHclickX = Int(IniRead("tt6.ini","click positions","GHclickX",0))
Const $GHclickY = Int(IniRead("tt6.ini","click positions","GHclickY",0))
Const $STclickX = Int(IniRead("tt6.ini","click positions","STclickX",0))
Const $STclickY = Int(IniRead("tt6.ini","click positions","STclickY",0))
Const $SBclickX = Int(IniRead("tt6.ini","click positions","SBclickX",0))
Const $SBclickY = Int(IniRead("tt6.ini","click positions","SBclickY",0))
Const $HMclickX = Int(IniRead("tt6.ini","click positions","HMclickX",0))
Const $HMclickY = Int(IniRead("tt6.ini","click positions","HMclickY",0))
;generate inventory access matrix adapt positions in the tt6.ini
Const $invMaxR = 8 ;max number of rows 0..8
Const $invMaxC = 4 ;max number of columns 0..4
Global $invPos[$invMaxC+1] [$invMaxR+1][2];matrix of positions [0]=x, [1]=y
$invPos[0][0][0] = Int(IniRead("tt6.ini","inventory offsets","invPosX00",0))
$invPos[0][0][1] = Int(IniRead("tt6.ini","inventory offsets","invPosY00",0))
$invPos[0][1][1] = Int(IniRead("tt6.ini","inventory offsets","invPosYR1",0))
$invPos[0][2][1] = Int(IniRead("tt6.ini","inventory offsets","invPosYR2",0))
$invPos[0][3][1] = Int(IniRead("tt6.ini","inventory offsets","invPosYR3",0))
$invPos[0][4][1] = Int(IniRead("tt6.ini","inventory offsets","invPosYR4",0))
$invPos[0][5][1] = Int(IniRead("tt6.ini","inventory offsets","invPosYR5",0))
$invPos[0][6][1] = Int(IniRead("tt6.ini","inventory offsets","invPosYR6",0))
$invPos[0][7][1] = Int(IniRead("tt6.ini","inventory offsets","invPosYR7",0))
$invPos[0][8][1] = Int(IniRead("tt6.ini","inventory offsets","invPosYR8",0))
$invPosXdelta = Int(IniRead("tt6.ini","inventory offsets","invPosXdelta",0))
For $ri=1 To 8
$invPos[0][$ri][0] = $invPos[0][0][0] ;x offset of 0 element constant in every row
Next
For $ri=0 To 8
For $ci=1 To 4
$invPos[$ci][$ri][0] = $invPos[0][$ri][0] + $invPosXdelta *$ci ; x offset increases by number of column
$invPos[$ci][$ri][1] = $invPos[0][$ri][1] ; y offset equal to 0 position in every row
Next
Next
;blacklist for CollectLoot
;position 0 contains number of valid entries
Const $CLBlackMax = 50
Global $CLBlackList[$CLBlackMax +1]
$CLBlackList[0] = 0
#EndRegion
#Region Movement Engine
; stop movement
Func StopMoveTo()
if Not $gotBlocked Then
KeySend($ARmovkey)
EndIf
$increment = 0
$callcnt = 0
$running = False
$stopCheck = False
$blockCheck = False
EndFunc
; end movement but keep running e.g. to exit
Func KeepMoveTo()
$increment = 0
$callcnt = 0
$running = False
$stopCheck = False
$blockCheck = False
EndFunc
; prepare movement
Func PrepMoveTo()
$increment = 0
$callcnt = 0
$stopCheck = False
$blockCheck = False
$gotBlocked = False
EndFunc
; disables check if we stopped runnning unintended (eg by cast or knock down)
; note: must be used to protect casts as we try to start running again immediately in auto mode
Func DisableStopCheck()
if $stopCheck Then
$stopCheck = False
EndIf
EndFunc
; enables check again
Func EnableStopCheck()
if ($blockCheck = False) And ($stopCheck = False) Then
$stopCheck = True
EndIf
EndFunc
; calc table for rotation angle calculation
Global $course_table[100]
$course_table[0] = 0.0000
$course_table[1] = 0.0000
$course_table[2] = 0.0000
$course_table[3] = 0.0438
$course_table[4] = 0.0702
$course_table[5] = 0.1031
$course_table[6] = 0.1377
$course_table[7] = 0.1466
$course_table[8] = 0.1751
$course_table[9] = 0.1824
$course_table[10] = 0.2076
$course_table[11] = 0.2462
$course_table[12] = 0.2551
$course_table[13] = 0.2750
$course_table[14] = 0.3154
$course_table[15] = 0.3337
$course_table[16] = 0.3528
$course_table[17] = 0.3612
$course_table[18] = 0.3800
$course_table[19] = 0.4078
$course_table[20] = 0.4273
$course_table[21] = 0.4458
$course_table[22] = 0.4670
$course_table[23] = 0.4845
$course_table[24] = 0.5120
$course_table[25] = 0.5361
$course_table[26] = 0.5656
$course_table[27] = 0.5936
$course_table[28] = 0.6285
$course_table[29] = 0.6445
$course_table[30] = 0.6643
$course_table[31] = 0.6848
$course_table[32] = 0.6991
$course_table[33] = 0.7136
$course_table[34] = 0.7214
$course_table[35] = 0.7452
$course_table[36] = 0.7746
$course_table[37] = 0.8052
$course_table[38] = 0.8283
$course_table[39] = 0.8410
$course_table[40] = 0.8666
$course_table[41] = 0.8826
$course_table[42] = 0.9062
$course_table[43] = 0.9195
$course_table[44] = 0.9363
$course_table[45] = 0.9531
$course_table[46] = 0.9759
$course_table[47] = 1.0020
$course_table[48] = 1.0203
$course_table[49] = 1.0448
$course_table[50] = 1.0636
$course_table[51] = 1.0882
$course_table[52] = 1.0957
$course_table[53] = 1.1124
$course_table[54] = 1.1474
$course_table[55] = 1.1669
$course_table[56] = 1.1833
$course_table[57] = 1.2264
$course_table[58] = 1.2469
$course_table[59] = 1.2670
$course_table[60] = 1.2876
$course_table[61] = 1.2957
$course_table[62] = 1.3056
$course_table[63] = 1.3331
$course_table[64] = 1.3529
$course_table[65] = 1.3769
$course_table[66] = 1.3975
$course_table[67] = 1.4162
$course_table[68] = 1.4366
$course_table[69] = 1.4684
$course_table[70] = 1.4844
$course_table[71] = 1.5089
$course_table[72] = 1.5223
$course_table[73] = 1.5420
$course_table[74] = 1.5721
$course_table[75] = 1.5994
$course_table[76] = 1.6089
$course_table[77] = 1.6203
$course_table[78] = 1.6485
$course_table[79] = 1.6632
$course_table[80] = 1.6791
$course_table[81] = 1.6807
$course_table[82] = 1.7258
$course_table[83] = 1.7630
$course_table[84] = 1.7801
$course_table[85] = 1.8172
$course_table[86] = 1.8256
$course_table[87] = 1.8400
$course_table[88] = 1.8654
$course_table[89] = 1.8804
$course_table[90] = 1.9119
$course_table[91] = 1.9391
$course_table[92] = 1.9605
$course_table[93] = 1.9822
$course_table[94] = 2.0091
$course_table[95] = 2.0203
$course_table[96] = 2.0433
$course_table[97] = 2.0654
$course_table[98] = 2.0749
$course_table[99] = 2*$pi
; calculate rotation angle
Func GetCourse($val)
$i=0
$valL = Abs($val)
While $course_table[$i] < $valL
$i +=1
if $i = 100 Then ;error
ConsoleWrite(StringFormat("GetCourse: bad call: %.4f",$valL))
Exit
EndIf
WEnd
return Int($i * 10 * $accelmul)
EndFunc
; initialise new destination
Func InitDest($dx, $dy, $dcheck = False)
;no movement if we are dead or got blocked
If $isDead Or $gotBlocked Then
Return
EndIf
; set global destination
$gotox = $dx
$gotoy = $dy
if $debug_pos Then
ConsoleWrite(StringFormat("InitDest: %d %d\n",$gotox, $gotoy))
EndIf
; calc distance
$posx = _memoryread($memx,$hprocess,'float')
$posy = _memoryread($memy,$hprocess,'float')
$dist = Sqrt(($posx-$gotox)^2 + ($posy-$gotoy)^2)
$olddist = $dist
;set call counter for cyclic loop
$callcnt = 1
; set stop level for angles in relation to distance
if $dist > 2000 Then
$stoplvl = 1.8
Elseif $dist > 1200 Then
$stoplvl = 1.5
Elseif $dist > 700 Then
$stoplvl = 1.2
Elseif $dist > 400 Then
$stoplvl = 0.8
Elseif $dist > 200 Then
$stoplvl = 0.6
Else
$stoplvl = 0.2
EndIf
; calc angle
$angle = ACos(($gotox - $posx)/$dist)
if $gotoy < $posy Then
$angle = -$angle
EndIf
; rotate view to destination
$cnt =0
Do
; transition via q2<->q3 by pseudo course angle
$curcou = _memoryread($memcourse,$hprocess,'float')
if (($angle > $pi/2) And ($curcou < $angle - $pi)) Then
$curcou = 2*$pi + $curcou
EndIf
if (($angle < -$pi/2) And ($curcou > $pi+$angle)) Then
$curcou = -2*$pi + $curcou
EndIf
; big delta -> stop running
if Abs($angle - $curcou) > $stoplvl Then
if $running = True Then
KeySend($ARmovkey)
$running = False
EndIf
EndIf
$accel = GetCourse(Abs($angle - $curcou))
; rotate
if $angle < $curcou Then
KeySend($TRmovkey, "down")
Sleep($accel)
KeySend($TRmovkey, "up")
if $debug_mov = True Then
ConsoleWrite(StringFormat("InitDest: %s %d %.4f %.0f\n",$TRmovkey ,$accel, $angle, $dist))
EndIf
Else
KeySend($TLmovkey, "down")
Sleep($accel)
KeySend($TLmovkey, "up")
if $debug_mov = True Then
ConsoleWrite(StringFormat("InitDest: %s %d %.4f %.0f\n",$TLmovkey ,$accel, $angle, $dist))
EndIf
EndIf
Sleep(100)
$cnt +=1
; check for death
if $dcheck And _memoryread($memdeath,$hprocess) = 1 Then
$isDead = True
Return
EndIf
; sometimes GW does not accept rotation keys, so just start movement and proceed with fingers crossed
Until (Abs($angle - $curcou) <0.1) Or ($cnt > 10)
EndFunc
; cyclic function for movement to destination (must be called every 10ms)
Func MoveToCore($okdist, $dcheck = False)
;no movement if we are dead or got blocked
If $isDead Or $gotBlocked Then
Return True
EndIf
; get data
$posx = _memoryread($memx,$hprocess,'float')
$posy = _memoryread($memy,$hprocess,'float')
$curcou = _memoryread($memcourse,$hprocess,'float')
; calc distance
$dist = Sqrt(($posx-$gotox)^2 + ($posy-$gotoy)^2)
; try to catch problem in case we missed target
if $olddist < $dist -100.0 Then
InitDest($gotox, $gotoy, $dcheck)
EndIf
; store distance every 500ms, initial value is set in InitDest(), check for special situations
If Mod($callcnt, 50) = 0 Then
; set death flag and exit
if $dcheck And _memoryread($memdeath,$hprocess) = 1 Then
$isDead = True
Return True
EndIf
; restart running in case we got stopped
if $stopCheck And (Abs($olddist - $dist) < 20.0) Then
$running = False
EndIf
; set blocked flag and exit
if $blockCheck And (Abs($olddist - $dist) < 20.0) Then
$gotBlocked = True
Return True
EndIf
$olddist = $dist
EndIf
;increment call counter
$callcnt +=1
; check running
if $running = False Then
$running = True
KeySend($ARmovkey)
EndIf
; calc angle
$angle = ACos(($gotox - $posx)/$dist)
if $gotoy < $posy Then
$angle = -$angle
EndIf
; correct angle on the fly
If (Abs($angle - $curcou) >0.1) And ($increment = 0) Then
; transition via q2<->q3 by pseudo course angle
$curcou = _memoryread($memcourse,$hprocess,'float')
if (($angle > $pi/2) And ($curcou < $angle - $pi)) Then
$curcou = 2*$pi + $curcou
EndIf
if (($angle < -$pi/2) And ($curcou > $pi+$angle)) Then
$curcou = -2*$pi + $curcou
EndIf
$increment = GetCourse(Abs($angle - $curcou))
; rotate
if $angle < $curcou Then
KeySend($TRmovkey, "down")
$increment -=10
if $debug_mov = True Then
ConsoleWrite(StringFormat("MoveToCore: %s %d %.4f %.0f\n",$TRmovkey ,$increment, $angle, $dist))
EndIf
Else
KeySend($TLmovkey, "down")
$increment -=10
if $debug_mov = True Then
ConsoleWrite(StringFormat("MoveToCore: %s %d %.4f %.0f\n",$TLmovkey ,$increment, $angle, $dist))
EndIf
EndIf
ElseIf ($increment > 0) Then
$increment -=10
if $increment <= 0 Then
KeySend($TRmovkey, "up")
KeySend($TLmovkey, "up")
EndIf
EndIf
; reached position
If $dist < $okdist Then
$increment = 0
KeySend($TRmovkey, "up")
KeySend($TLmovkey, "up")
if $debug_pos Then
ConsoleWrite(StringFormat("MoveToCore: %d %d\n",$gotox, $gotoy))
EndIf
return True
EndIf
Return False
EndFunc
; movement function
; $mode = 0 : do one iteration and return, used in very special situations only
; $mode = 1 : init destination and move there
; $mode = 2 : autorun mode, if a stop is detected it will be tried to run again automatically
; $mode = 3 : block mode, if a block is detected we set flag and exit
; $random adds some variation to movement positions
; $dcheck enables deathcheck
; $okdist specifies the distance to the destination which will be accepted as position reached
Func MoveTo($mode, $x, $y, $random = False, $dcheck = False, $okdist = 130.0)
$xl = $x
$yl = $y
if $random Then
$xl = $x + Int(Random(-100,100))
$yl = $y + Int(Random(-100,100))
EndIf
if $mode = 0 Then
$stopCheck = False
$blockCheck = False
Return MoveToCore($okdist, $dcheck)
ElseIf $mode = 1 Then
$stopCheck = False
$blockCheck = False
InitDest($xl, $yl, $dcheck)
While Not MoveToCore($okdist, $dcheck)
Sleep(10)
WEnd
ElseIf $mode = 2 Then
$stopCheck = True
$blockCheck = False
InitDest($xl, $yl, $dcheck)
While Not MoveToCore($okdist, $dcheck)
Sleep(10)
WEnd
ElseIf $mode = 3 Then
$stopCheck = False
$blockCheck = True
InitDest($xl, $yl, $dcheck)
While Not MoveToCore($okdist, $dcheck)
Sleep(10)
WEnd
Else ;error
ConsoleWrite(StringFormat("MoveTo: bad mode: %d",$mode))
Exit
EndIf
EndFunc
#EndRegion
#Region Collection of Functions
; check if position is in area
Func CheckArea($xval, $yval)
$ret = False
$pX = _memoryread($memx,$hprocess,'float')
$pY = _memoryread($memy,$hprocess,'float')
if ($pX < $xval + 250) And ($pX > $xval - 250) And ($pY < $yval + 250) And ($pY > $yval - 250) Then
$ret = True
EndIf
Return $ret
EndFunc
; random sleep function with -+5% variation
Func RndSleep($val)
$sle = Random($val * 0.95, $val *1.05, 1)
Sleep($sle)
EndFunc
;check if we got killed
Func CheckDeath()
if _memoryread($memdeath,$hprocess) = 1 Then
$isDead = true
return true
EndIf
EndFunc
;enable hardmode
func EnableHM()
MouseSend("left", "click", $HMclickX, $HMclickY)
EndFunc
; check area for not collectable items like chests/signs etc.
Func BuildCLBlackList()
$CLBlackList[0] = 0
KeySend($INtgtkey)
Sleep(200)
$cnt = 0
$id = _memoryread($memnpcidselect,$hprocess)
While ( $id > 0 And $cnt < $CLBlackMax)
for $i=1 to $cnt
If $CLBlacklist[$i] = $id Then ExitLoop 2
Next
$cnt +=1
$CLBlackList[$cnt] = $id
KeySend($IXtgtkey)
Sleep(200)
$id = _memoryread($memnpcidselect,$hprocess)
WEnd
$CLBlackList[0] = $cnt
EndFunc
; collect loot
; $max limits number of items to pick up
; $checkblack enables usage of blacklist generated by a call to BuildCLBlackList()
; $retrytime specifies the time in ms to do another attempt to collect the item,
; useful if items may be spread all over the place after a farm run
; $retrycount specifies how many retry attempts should be done until item gets blacklisted
; (e.g. blocked by an foe)
Func CollectLoot($max, $checkblack = False, $retrytime = 200, $retrycount = 0)
$cnt =0
If $checkblack Then
$max += $CLBlackList[0]
Else
; clear old blacklist
$CLBlackList[0] =0
EndIf
;select first item
KeySend($INtgtkey)
RndSleep(200)
$id = _memoryread($memnpcidselect,$hprocess)
While ( $id > 0) And ($cnt < $max)
;check for death
If (_memoryread($memdeath,$hprocess) = 1) Then ExitLoop
;check if item has been blacklisted
If $checkblack Then
For $i = 1 To $CLBlackList[0]
If $CLBlackList[$i] = $id Then
KeySend($IXtgtkey)
RndSleep(200)
$id = _memoryread($memnpcidselect,$hprocess)
$cnt +=1
ContinueLoop 2
EndIf
Next
EndIf
;check if looting has been disabled
$CLtimer = TimerInit()
While $noLoot
$CLtime = TimerDiff($CLtimer)
Sleep(500)
If $CLtime > 30000 Then ;noLoot timeout
ConsoleWrite("CollectLoot: noLoot timeout exceeded")
Exit
EndIf
WEnd
;collect item
$rcnt = 0
KeySend($DIactkey)
RndSleep(200)
$CLtimer = TimerInit()
While ($id = _memoryread($memnpcidselect,$hprocess))
Sleep(100)
;wait if we have to run a longer distance
$CLtime = TimerDiff($CLtimer)
if $CLtime > $retrytime Then
;dont do a retry just wait retrytime
if $retrycount = 0 Then ExitLoop
;try again
KeySend($DIactkey)
$rcnt +=1
;max retries reached, check if still not collected and blacklist item
if $rcnt = $retrycount Then
RndSleep(200)
If ($id = _memoryread($memnpcidselect,$hprocess)) Then
$checkblack = True
$enter = True
for $i=1 to $CLBlackList[0]
If $CLBlacklist[$i] = $id Then
$enter = False
EndIf
Next
if $enter Then
$CLBlackList[0] +=1
$CLBlackList[$CLBlackList[0]] = $id
EndIf
EndIf
ExitLoop
EndIf
$CLtimer = TimerInit()
EndIf
;check for death
If (_memoryread($memdeath,$hprocess) = 1) Then ExitLoop 2
WEnd
;select next item
KeySend($INtgtkey)
RndSleep(200)
$id = _memoryread($memnpcidselect,$hprocess)
$cnt +=1
WEnd
EndFunc
; resign
Func Resign($wdelay = 50)
$cnt = 0
Do
keysend("-")
Sleep($wdelay)
keysend("r")
Sleep($wdelay)
keysend("e")
Sleep($wdelay)
keysend("s")
Sleep($wdelay)
keysend("i")
Sleep($wdelay)
keysend("g")
Sleep($wdelay)
keysend("n")
Sleep($wdelay)
keysend("RETURN")
RndSleep(5500)
$cnt +=1
Until (_memoryread($memdeath,$hprocess) = 1) Or $cnt >3
ControlClick($client, "", "", "left", 1, $DTclickX, $DTclickY)
EndFunc
; wait until dead and got rezzed
Func WaitRezz()
While _memoryread($memdeath,$hprocess) <> 1
Sleep(2000)
WEnd
While _memoryread($memdeath,$hprocess) <> 0
Sleep(2000)
WEnd
RndSleep(3000)
EndFunc
; transfer to different area / portal
; $toID specifies area we want to travel to
; $timeout is the time in sec after we exit with an error
Func TransferArea($toID, $timeout = 20)
; wait until transfer has started
$cnt = 0
While Not ((_memoryread($memmap,$hprocess)) = 2)
Sleep(200)
$cnt +=1
if $cnt > 5*$timeout Then
ConsoleWrite("TransferArea: transfer timeout exceeded")
Exit
EndIf
WEnd
;wait until new area has been reached
$cnt = 0
While (_memoryread($memmap,$hprocess)) <> $toID
Sleep(200)
$cnt +=1
if $cnt > 5*$timeout Then
ConsoleWrite(StringFormat("TransferArea: area ID: %d timeout exceeded", $toID))
Exit
EndIf
WEnd
RndSleep(4000)
;wait until course has been stabilized
$cnt = 0
While _memoryread($memcourse,$hprocess,'float') > 2*$pi
Sleep(200)
$cnt +=1
if $cnt > 5*$timeout Then
ConsoleWrite("TransferArea: course timeout exceeded")
Exit
EndIf
WEnd
EndFunc
; transfer to GH, may be used from/to GH
Func TransferGH()
KeySend($OGpnlkey)
RndSleep(500)
ControlClick($client, "", "", "left", 1, $GHclickX, $GHclickY)
$cnt = 0
While Not ((_memoryread($memmap,$hprocess)) = 2)
Sleep(200)
$cnt +=1
if Mod($cnt, 10) = 0 Then
ControlClick($client, "", "", "left", 1, $GHclickX, $GHclickY)
EndIf
if Mod($cnt, 15) = 0 Then
KeySend($OGpnlkey)
EndIf
WEnd
While (_memoryread($memmap,$hprocess)) <> 0
Sleep(100)
WEnd
RndSleep(4000)
KeySend($OGpnlkey)
RndSleep(500)
EndFunc
; ident all items from start row to end row (0..8) using ident kit at row/col (0..4)
Func IdentItems($StartRow, $EndRow, $IdentCol, $IdentRow)
KeySend($TBinvkey)
RndSleep(500)
if $EndRow > $invMaxR Then
$end = $invMaxR
Else
$end = $EndRow
EndIf
For $row = $StartRow To $end
For $col = 0 To $invMaxC
MouseSend("left", "dclick", $invPos[$IdentCol][$IdentRow][0], $invPos[$IdentCol][$IdentRow][1])
RndSleep(250)
MouseSend("left", "click", $invPos[$col][$row][0], $invPos[$col][$row][1])
RndSleep(250)
Next
Next
RndSleep(500)
KeySend($TBinvkey)
EndFunc
;Sell items at trader
func SellatTrader($countclicks)
KeySend($ANtgtkey)
RndSleep(500)
KeySend($DIactkey)
RndSleep(2000)
MouseSend("left", "click", $STclickX, $STclickY)
RndSleep(200)
for $i = 1 to $countclicks
MouseSend("left", "click", $SBclickX, $SBclickY)
RndSleep(200)
Next
EndFunc
#EndRegion
#Region Helper Functions
; create long int (32 bit) from 2 short int (16 bit)
Func MakeLong($LoWord, $HiWord)
Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF))
EndFunc
; send mouse events to non active window
; button = left, right, none
; event = down, up, click, dclick, move
Func MouseSend($btn, $evt, $xpos, $ypos)
$user32 = DllOpen("user32.dll")
if $user32 = -1 Then
ConsoleWrite("MouseSend: cannot open user32.dll")
Exit
EndIf
;define missing constans
$MK_LBUTTON = 0x0001
$WM_LBUTTONDOWN = 0x0201
;$WM_LBUTTONUP = 0x0202 -> defined in WindowsConstants.au3
$WM_LBUTTONDBLCLK = 0x0203
$MK_RBUTTON = 0x0002
$WM_RBUTTONDOWN = 0x0204
$WM_RBUTTONUP = 0x0205
$WM_RBUTTONDBLCLK = 0x0206
;$WM_MOUSEMOVE = 0x0200 -> defined in WindowsConstants.au3
;map button to event
If $btn = "left" Then
$button = $MK_LBUTTON
$btdown = $WM_LBUTTONDOWN
$btup = $WM_LBUTTONUP
$btdbl = $WM_LBUTTONDBLCLK
ElseIf $btn = "right" Then
$button = $MK_RBUTTON
$btdown = $WM_RBUTTONDOWN
$btup = $WM_RBUTTONUP
$btdbl = $WM_RBUTTONDBLCLK
ElseIf $btn = "none" Then
If Not ($evt = "move") Then
ConsoleWrite(StringFormat("MouseSend: bad call: %s , %s",$btn, $evt))
Exit
EndIf
Else ;error
ConsoleWrite(StringFormat("MouseSend: bad button: %s",$btn))
Exit
EndIf
;send messages
$pos = MakeLong($xpos, $ypos)
Select
Case $evt = "move"
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_MOUSEMOVE, "int", 0, "long", $pos)
Case $evt = "down"
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $btdown, "int", $button, "long", $pos)
Case $evt = "up"
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $btup, "int", 0, "long", $pos)
Case $evt = "click"
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_MOUSEMOVE, "int", 0, "long", $pos)
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $btdown, "int", $button, "long", $pos)
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $btup, "int", 0, "long", $pos)
Case $evt = "dclick"
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_MOUSEMOVE, "int", 0, "long", $pos)
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $btdown, "int", $button, "long", $pos)
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $btup, "int", 0, "long", $pos)
Sleep(10)
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $btdbl, "int", $button, "long", $pos)
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $btup, "int", 0, "long", $pos)
EndSelect
DllClose($user32)
EndFunc
; send single keyboard event to non active window
; event = pressed, down, up
; kdown = key down delay
; note: supports only lower case keys + NUMx, Fx, some special keys and @
Func KeySend($inkey, $evt ="pressed", $kdown = 50)
$user32 = DllOpen("user32.dll")
if $user32 = -1 Then
ConsoleWrite("KeySend: cannot open user32.dll")
Exit
EndIf
; handling for special keys
Switch StringUpper($inkey)
Case "@"
$skey = 0x40
$lparam = 0x00100001
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_KEYDOWN, "int", 0x71, "long", $lparam)
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_CHAR, "int", $skey, "long", $lparam)
Sleep(20)
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_KEYUP, "int", 0x71, "long", BitOR($lparam, 0xC0000000))
Case "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12"
$skey = 0x6f + Int(StringMid($inkey, 2))
ContinueCase
Case "NUM0", "NUM1", "NUM2", "NUM3", "NUM4", "NUM5", "NUM6", "NUM7", "NUM8" , "NUM9"
if StringUpper(StringLeft($inkey, 3)) = "NUM" Then
$skey = 0x60 + Int(StringMid($inkey, 4))
EndIf
ContinueCase
Case "RETURN", "SPACE", "TAB", "BACK", "END", "HOME", "SNAPSHOT", "INSERT", "DELETE", "LEFT", "RIGHT", "UP", "DOWN"
Switch StringUpper($inkey)
Case "RETURN"
$skey = 0x0D
Case "SPACE"
$skey = 0x20
Case "TAB"
$skey = 0x09
Case "BACK"
$skey = 0x08
Case "END"
$skey = 0x23
Case "HOME"
$skey = 0x24
Case "SNAPSHOT"
$skey = 0x2c
Case "INSERT"
$skey = 0x2d
Case "DELETE"
$skey = 0x2e
Case "LEFT"
$skey = 0x25
Case "RIGHT"
$skey = 0x27
Case "UP"
$skey = 0x26
Case "DOWN"
$skey = 0x28
EndSwitch
$ret = DllCall($user32, "int", "MapVirtualKey", "int", $skey, "int", 0)
$lparam = BitShift($ret[0], -16)
$lparam = BitOr($lparam, 1)
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_KEYDOWN, "int", $skey, "long", $lparam)
Sleep($kdown)
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_KEYUP, "int", $skey, "long", BitOR($lparam, 0xC0000000))
Case Else ; default lower case key handling
$key = DllCall($user32, "int", "VkKeyScan", "int", Asc(StringLower($inkey)))
$skey = $key[0]
$ret = DllCall($user32, "int", "MapVirtualKey", "int", $skey, "int", 0)
$lparam = BitShift($ret[0], -16)
$lparam = BitOr($lparam, 1)
Select
Case $evt = "pressed"
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_KEYDOWN, "int", $skey, "long", $lparam)
Sleep($kdown)
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_KEYUP, "int", $skey, "long", BitOR($lparam, 0xC0000000))
Case $evt = "down"
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_KEYDOWN, "int", $skey, "long", $lparam)
Case $evt = "up"
DllCall($user32, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_KEYUP, "int", $skey, "long", BitOR($lparam, 0xC0000000))
EndSelect
EndSwitch
DllClose($user32)
EndFunc
#EndRegion
Dumper.au3
#cs ----------------------------------------------------------------------------
Dumper - simple tool to create code snippets
#ce ----------------------------------------------------------------------------
#include "tt6.au3"
#include <WindowsConstants.au3>
Global $leftupX =530, $leftupY =30 , $rightdownX =662, $rightdownY =44
;info window
$win = GUICreate("Status Window", 200, 200, 5, 5, "", $WS_EX_TOPMOST)
$label_mou = GUICtrlCreateLabel("x: 0000 y: 0000 ", 10, 10)
$label_pos = GUICtrlCreateLabel("x: -00000.00 y:-00000.00 ", 10, 30)
$label_cou = GUICtrlCreateLabel("c: -00000.0000 ", 10, 50)
$label_col = GUICtrlCreateLabel("color: AABBCCDD ", 10, 70)
$label_reg = GUICtrlCreateLabel("regio: 1230 1230 1230 1230", 10, 90)
$label_chk = GUICtrlCreateLabel("check: AABBCCDD ", 10, 110)
$label_ded = GUICtrlCreateLabel("dead: AABBCCDD ", 10, 130)
$label_are = GUICtrlCreateLabel("area: AABBCCDD ", 10, 150)
GUISetState(@SW_SHOW)
;gw
If Not WinActivate($client) Then
WinActivate($client)
EndIf
;key handler
HotKeySet("{NUMPAD0}", "writepos")
HotKeySet("{NUMPAD1}", "writemouse")
HotKeySet("{NUMPAD7}", "leftupmouse")
HotKeySet("{NUMPAD8}", "rightdownmouse")
HotKeySet("{NUMPAD9}", "writerectangle")
HotKeySet("{END}", "stop")
;delete old file
FileDelete("dump.txt")
Func writepos()
$posx = _memoryread($memx,$hprocess,'float')
$posy = _memoryread($memy,$hprocess,'float')
$string = StringFormat("MoveTo(1, %d, %d)\n", $posx, $posy)
FileWriteLine("dump.txt", $string)
ConsoleWrite($string)
EndFunc
Func writemouse()
$mpos = MouseGetPos()
$string = "MouseClick(" & '"' & "left" & '"' & StringFormat(", %d, %d)\n", $mpos[0], $mpos[1])
FileWriteLine("dump.txt", $string)
ConsoleWrite($string)
EndFunc
Func writerectangle()
$string = StringFormat("%4u %4u %4u %4u %.0f\n",$leftupX ,$leftupY ,$rightdownX ,$rightdownY, PixelChecksum($leftupX, $leftupY, $rightdownX, $rightdownY))
FileWriteLine("dump.txt", $string)
ConsoleWrite($string)
EndFunc
Func leftupmouse()
$mpos = MouseGetPos()
$leftupX = $mpos[0]
$leftupY = $mpos[1]
EndFunc
Func rightdownmouse()
$mpos = MouseGetPos()
$rightdownX = $mpos[0]
$rightdownY = $mpos[1]
EndFunc
Func stop()
Exit
EndFunc
While True
$course = _memoryread($memcourse,$hprocess,'float')
$posx = _memoryread($memx,$hprocess,'float')
$posy = _memoryread($memy,$hprocess,'float')
$dead = _memoryread($memdeath,$hprocess)
$area = _memoryread($memmap,$hprocess)
$string = StringFormat("x: %.2f y: %.2f", $posx, $posy)
GUICtrlSetData($label_pos, $string)
$string = StringFormat("c: %.4f", $course)
GUICtrlSetData($label_cou, $string)
$mpos = MouseGetPos()
$string = StringFormat("x: %4u y: %4u", $mpos[0], $mpos[1])
GUICtrlSetData($label_mou, $string)
$string = StringFormat("color: %x", PixelGetColor($mpos[0], $mpos[1]))
GUICtrlSetData($label_col, $string)
$string = StringFormat("regio: %4u %4u %4u %4u", $leftupX, $leftupY, $rightdownX, $rightdownY)
GUICtrlSetData($label_reg, $string)
$string = StringFormat("check: %.0f", PixelChecksum($leftupX, $leftupY, $rightdownX, $rightdownY, "", $hwnd))
GUICtrlSetData($label_chk, $string)
$string = StringFormat("dead: %d", $dead)
GUICtrlSetData($label_ded, $string)
$string = StringFormat("area: %d", $area)
GUICtrlSetData($label_are, $string)
Sleep(200)
WEnd
Dumper - simple tool to create code snippets
#ce ----------------------------------------------------------------------------
#include "tt6.au3"
#include <WindowsConstants.au3>
Global $leftupX =530, $leftupY =30 , $rightdownX =662, $rightdownY =44
;info window
$win = GUICreate("Status Window", 200, 200, 5, 5, "", $WS_EX_TOPMOST)
$label_mou = GUICtrlCreateLabel("x: 0000 y: 0000 ", 10, 10)
$label_pos = GUICtrlCreateLabel("x: -00000.00 y:-00000.00 ", 10, 30)
$label_cou = GUICtrlCreateLabel("c: -00000.0000 ", 10, 50)
$label_col = GUICtrlCreateLabel("color: AABBCCDD ", 10, 70)
$label_reg = GUICtrlCreateLabel("regio: 1230 1230 1230 1230", 10, 90)
$label_chk = GUICtrlCreateLabel("check: AABBCCDD ", 10, 110)
$label_ded = GUICtrlCreateLabel("dead: AABBCCDD ", 10, 130)
$label_are = GUICtrlCreateLabel("area: AABBCCDD ", 10, 150)
GUISetState(@SW_SHOW)
;gw
If Not WinActivate($client) Then
WinActivate($client)
EndIf
;key handler
HotKeySet("{NUMPAD0}", "writepos")
HotKeySet("{NUMPAD1}", "writemouse")
HotKeySet("{NUMPAD7}", "leftupmouse")
HotKeySet("{NUMPAD8}", "rightdownmouse")
HotKeySet("{NUMPAD9}", "writerectangle")
HotKeySet("{END}", "stop")
;delete old file
FileDelete("dump.txt")
Func writepos()
$posx = _memoryread($memx,$hprocess,'float')
$posy = _memoryread($memy,$hprocess,'float')
$string = StringFormat("MoveTo(1, %d, %d)\n", $posx, $posy)
FileWriteLine("dump.txt", $string)
ConsoleWrite($string)
EndFunc
Func writemouse()
$mpos = MouseGetPos()
$string = "MouseClick(" & '"' & "left" & '"' & StringFormat(", %d, %d)\n", $mpos[0], $mpos[1])
FileWriteLine("dump.txt", $string)
ConsoleWrite($string)
EndFunc
Func writerectangle()
$string = StringFormat("%4u %4u %4u %4u %.0f\n",$leftupX ,$leftupY ,$rightdownX ,$rightdownY, PixelChecksum($leftupX, $leftupY, $rightdownX, $rightdownY))
FileWriteLine("dump.txt", $string)
ConsoleWrite($string)
EndFunc
Func leftupmouse()
$mpos = MouseGetPos()
$leftupX = $mpos[0]
$leftupY = $mpos[1]
EndFunc
Func rightdownmouse()
$mpos = MouseGetPos()
$rightdownX = $mpos[0]
$rightdownY = $mpos[1]
EndFunc
Func stop()
Exit
EndFunc
While True
$course = _memoryread($memcourse,$hprocess,'float')
$posx = _memoryread($memx,$hprocess,'float')
$posy = _memoryread($memy,$hprocess,'float')
$dead = _memoryread($memdeath,$hprocess)
$area = _memoryread($memmap,$hprocess)
$string = StringFormat("x: %.2f y: %.2f", $posx, $posy)
GUICtrlSetData($label_pos, $string)
$string = StringFormat("c: %.4f", $course)
GUICtrlSetData($label_cou, $string)
$mpos = MouseGetPos()
$string = StringFormat("x: %4u y: %4u", $mpos[0], $mpos[1])
GUICtrlSetData($label_mou, $string)
$string = StringFormat("color: %x", PixelGetColor($mpos[0], $mpos[1]))
GUICtrlSetData($label_col, $string)
$string = StringFormat("regio: %4u %4u %4u %4u", $leftupX, $leftupY, $rightdownX, $rightdownY)
GUICtrlSetData($label_reg, $string)
$string = StringFormat("check: %.0f", PixelChecksum($leftupX, $leftupY, $rightdownX, $rightdownY, "", $hwnd))
GUICtrlSetData($label_chk, $string)
$string = StringFormat("dead: %d", $dead)
GUICtrlSetData($label_ded, $string)
$string = StringFormat("area: %d", $area)
GUICtrlSetData($label_are, $string)
Sleep(200)
WEnd
Ich hoffe ihr könnt mir helfen und ich habe bei meinem 1. Post im Forum hier alles richtig gemacht.
schon mal im voraus!Antivir: Nothing found
ArcaVir: Nothing found
AVG: Nothing found
BitDefender: Nothing found
VirusBlokAda32: Nothing found
VirusBuster: Nothing found

Scanned by







