I gotta use this, since UNF doesn't allow for unique loot keys. The tutorial for finding the memory access is helpful as well. Thanks for your service :)
And again 3 more Lines in following else statement.
Lastly, the for $checked was deleted and instead these kinds of lines were added after each checkbox was created:
#RequireAdmin
#Region
#AutoIt3Wrapper_Icon=gw2-metro.ico
#AutoIt3Wrapper_Outfile=GW2_Toolbox.exe
#AutoIt3Wrapper_UseUpx=y
#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_Res_Description=Guild Wars 2 Toolbox
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#EndRegion
Global $GUI_EVENT_CLOSE=-3, $pid = 0, $open=0, $loot = 0, $timed = 0, $lootkey, $lootaddr_ini, $clicker_key, $anti_afk_checked, $autoloot_checked, $clicker_checked
$Admin = IsAdmin()
If $Admin <> 1 Then
MsgBox(0x30, "ERROR", "You must run this app as Administrator!")
Exit
EndIf
Opt("TrayMenuMode", 3)
$Exit = TrayCreateItem("Exit")
#Initialization
If Not FileExists("GW2_Toolbox.ini") Then
IniWrite("GW2_Toolbox.ini", "main", "lootkey", "f")
IniWrite("GW2_Toolbox.ini", "main", "lootaddress", "0x158524B")
IniWrite("GW2_Toolbox.ini", "main", "clicker_key", "{NUMPAD0}")
IniWrite("GW2_Toolbox.ini", "pref", "anti_afk_checked", "0")
IniWrite("GW2_Toolbox.ini", "pref", "autoloot_checked", "1")
IniWrite("GW2_Toolbox.ini", "pref", "clicker_checked", "0")
Else
$lootkey = IniRead("GW2_Toolbox.ini", "main", "lootkey", "f")
$lootaddr_ini = IniRead("GW2_Toolbox.ini", "main", "lootaddress", "")
$clicker_key = IniRead("GW2_Toolbox.ini", "main", "clicker_key", "{NUMPAD0}")
$anti_afk_checked = IniRead("GW2_Toolbox.ini", "main", "anti_afk_checked", "0")
$autoloot_checked = IniRead("GW2_Toolbox.ini", "main", "autoloot_checked", "1")
$clicker_checked = IniRead("GW2_Toolbox.ini", "main", "clicker_checked", "0")
EndIf
$GW2Tool = GUICreate("GW2 Toolbox", 220, 100, -1, -1)
GUISetIcon('/gw2-metro.ico')
$Checkbox1 = GUICtrlCreateCheckbox(" Anti AFK", 10, 10)
GUICtrlSetTip(-1, "Moves the character every 4 min. automatically" & @CRLF & "(GW2 window do not need to be active)")
GUICtrlSetState(-1, $anti_afk_checked)
$Checkbox2 = GUICtrlCreateCheckbox(" Autoloot", 10, 40)
GUICtrlSetTip(-1, "Automatically collects bags, boxes, etc.")
GUICtrlSetState(-1, $autoloot_checked)
$Checkbox3 = GUICtrlCreateCheckbox(" Clicker", 10, 70)
GUICtrlSetTip(-1, "Mouseover an item in the inventory and press " & @CRLF & "the clicker key. The item stack is emptied quickly." & @CRLF & "Clickerkey: " & $clicker_key)
GUICtrlSetState(-1, $clicker_checked)
$btninfo = GUICtrlCreateButton("?", 195, 75, 20, 20)
GUICtrlSetTip(-1, "Information" & @CRLF & "")
For $Checkbox = $Checkbox1 To $Checkbox3
GUICtrlSetState($Checkbox, 128)
Next
GUISetState(@SW_SHOW)
While $pid = 0
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
CleanUp()
Case $btninfo
info()
EndSwitch
Switch TrayGetMsg()
Case $Exit
CleanUp()
EndSwitch
$pid = ProcessExists("Gw2.exe")
WEnd
For $Checkbox = $Checkbox1 To $Checkbox3
GUICtrlSetState($Checkbox, 64)
Next
GUISetBkColor(0xFFFFFF)
SetPrivilege("SeDebugPrivilege", 1)
$open = _MemoryOpen($pid)
$baseAddr = _MemoryModuleGetBaseAddress($pid, "Gw2.exe")
$lootaddr = $baseAddr + $lootaddr_ini
$timer = TimerInit()
While 1
;Autoloot
If GUICtrlRead($Checkbox2) = 1 Then
If WinActive("[CLASS:ArenaNet_Dx_Window_Class]") Then
$loot = _MemoryRead($lootaddr, $open)
If $loot = 64 Then
ControlSend("","",0,$lootkey)
Sleep(20)
EndIf
EndIf
EndIf
;Anti AFK
If GUICtrlRead($Checkbox1) = 1 Then Anti_AFK()
;Clicker
If GUICtrlRead($Checkbox3) = 1 Then
HotKeySet($clicker_key, "clicker")
Else
HotKeySet($clicker_key) ;kill hotkey
EndIf
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
CleanUp()
Case $btninfo
info()
EndSwitch
Switch TrayGetMsg()
Case $Exit
CleanUp()
EndSwitch
$pid = ProcessExists("Gw2.exe")
If $pid = 0 Then CleanUp()
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 SetPrivilege( $privilege, $bEnable )
Const $TOKEN_ADJUST_PRIVILEGES = 0x0020
Const $TOKEN_QUERY = 0x0008
Const $SE_PRIVILEGE_ENABLED = 0x0002
Local $hToken, $SP_auxret, $SP_ret, $hCurrProcess, $nTokens, $nTokenIndex, $priv
$nTokens = 1
$LUID = DLLStructCreate("dword;int")
If IsArray($privilege) Then $nTokens = UBound($privilege)
$TOKEN_PRIVILEGES = DLLStructCreate("dword;dword[" & (3 * $nTokens) & "]")
$NEWTOKEN_PRIVILEGES = DLLStructCreate("dword;dword[" & (3 * $nTokens) & "]")
$hCurrProcess = DLLCall("kernel32.dll","hwnd","GetCurrentProcess")
$SP_auxret = DLLCall("advapi32.dll","int","OpenProcessToken","h wnd",$hCurrProcess[0], _
"int",BitOR($TOKEN_ADJUST_PRIVILEGES,$TOKEN_QUERY) ,"int*",0)
If $SP_auxret[0] Then
$hToken = $SP_auxret[3]
DLLStructSetData($TOKEN_PRIVILEGES,1,1)
$nTokenIndex = 1
While $nTokenIndex <= $nTokens
If IsArray($privilege) Then
$priv = $privilege[$nTokenIndex-1]
Else
$priv = $privilege
EndIf
$ret = DLLCall("advapi32.dll","int","LookupPrivilegeValue ","str","","str",$priv, _
"ptr",DLLStructGetPtr($LUID))
If $ret[0] Then
If $bEnable Then
DLLStructSetData($TOKEN_PRIVILEGES,2,$SE_PRIVILEGE _ENABLED,(3 * $nTokenIndex))
Else
DLLStructSetData($TOKEN_PRIVILEGES,2,0,(3 * $nTokenIndex))
EndIf
DLLStructSetData($TOKEN_PRIVILEGES,2,DllStructGetD ata($LUID,1),(3 * ($nTokenIndex-1)) + 1)
DLLStructSetData($TOKEN_PRIVILEGES,2,DllStructGetD ata($LUID,2),(3 * ($nTokenIndex-1)) + 2)
DLLStructSetData($LUID,1,0)
DLLStructSetData($LUID,2,0)
EndIf
$nTokenIndex += 1
WEnd
$ret = DLLCall("advapi32.dll","int","AdjustTokenPrivilege s","hwnd",$hToken,"int",0, _
"ptr",DllStructGetPtr($TOKEN_PRIVILEGES),"int",Dll StructGetSize($NEWTOKEN_PRIVILEGES), _
"ptr",DllStructGetPtr($NEWTOKEN_PRIVILEGES),"int*" ,0)
$f = DLLCall("kernel32.dll","int","GetLastError")
EndIf
$NEWTOKEN_PRIVILEGES=0
$TOKEN_PRIVILEGES=0
$LUID=0
If $SP_auxret[0] = 0 Then Return 0
$SP_auxret = DLLCall("kernel32.dll","int","CloseHandle","hwnd", $hToken)
If Not $ret[0] And Not $SP_auxret[0] Then Return 0
return $ret[0]
EndFunc
Func _MemoryModuleGetBaseAddress($iPID, $sModule)
If Not ProcessExists($iPID) Then Return SetError(1, 0, 0)
If Not IsString($sModule) Then Return SetError(2, 0, 0)
Local $PSAPI = DllOpen("psapi.dll")
Local $hProcess
Local $PERMISSION = BitOR(0x0002, 0x0400, 0x0008, 0x0010, 0x0020)
If $iPID > 0 Then
Local $hProcess = DllCall("kernel32.dll", "ptr", "OpenProcess", "dword", $PERMISSION, "int", 0, "dword", $iPID)
If $hProcess[0] Then
$hProcess = $hProcess[0]
EndIf
EndIf
Local $Modules = DllStructCreate("ptr[1024]")
Local $aCall = DllCall($PSAPI, "int", "EnumProcessModules", "ptr", $hProcess, "ptr", DllStructGetPtr($Modules), "dword", DllStructGetSize($Modules), "dword*", 0)
If $aCall[4] > 0 Then
Local $iModnum = $aCall[4] / 4
Local $aTemp
For $i = 1 To $iModnum
$aTemp = DllCall($PSAPI, "dword", "GetModuleBaseNameW", "ptr", $hProcess, "ptr", Ptr(DllStructGetData($Modules, 1, $i)), "wstr", "", "dword", 260)
If $aTemp[3] = $sModule Then
DllClose($PSAPI)
Return Ptr(DllStructGetData($Modules, 1, $i))
EndIf
Next
EndIf
DllClose($PSAPI)
Return SetError(-1, 0, 0)
EndFunc
Func CleanUp()
_MemoryClose($open)
Exit
EndFunc
Func Anti_AFK()
$timed = TimerDiff($timer)
If $timed >240000 Then
ControlSend("[CLASS:ArenaNet_Dx_Window_Class]", "", 0, "{w down}")
Sleep(500)
ControlSend("[CLASS:ArenaNet_Dx_Window_Class]", "", 0, "{w up}")
ControlSend("[CLASS:ArenaNet_Dx_Window_Class]", "", 0, "{s down}")
Sleep(1300)
ControlSend("[CLASS:ArenaNet_Dx_Window_Class]", "", 0, "{s up}")
$timer = TimerInit()
EndIf
EndFunc
Func info()
MsgBox(0+64, "Info", "Guild Wars 2 - WvW Tool" & @CR & @CR & "© 2015" & " Kellerkind",6)
EndFunc
Func clicker()
MouseClick("left")
EndFunc
I also added another script which others may find useful named "GW2+.au3". It is very simple and opens both programs at once:
Also as you can see I re-named it GW2 Toolbox, since it can be used outside WvW ;)
Changing default checkbox settings is done through .ini as before. 0 = off, 1 = on. For users that are looking at this (OP would def know this already).
* Always On Top mode for clicker on/off or a hotkey to turn it on / off? Idk. Either method is fine I suppose.
* Remove "0x" from lootaddress and include this inside the .au3/.exe script in front of the string. Easier for users to update, less thinking, etc.