Code:
#RequireAdmin
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
#include <Array.au3>
#include <GuiComboBox.au3>
#include <FastFind.au3>
Opt("WinTitleMatchMode", 3)
Opt("GUIOnEventMode", 1)
Opt("PixelCoordMode", 0)
Opt("MouseCoordMode", 0)
Opt("TrayIconDebug", 1)
; Block input while walk to adria? Doesn't work for everyone!
Global $blockInput = True ; Set this to "False" if input will not blocked
Global $resetOldValues = True ; Set this to "False" if not reset window and mouse position after walk to adria
; If you enable this, you cannot move your mouse or anything else until it works to adria!
Global $dll = DllOpen("user32.dll")
Global $status = False, $leecherHandle, $hostHandle
Global $processList = ProcessList("Diablo III.exe")
$Form1 = GUICreate("ZKScript by Nachto (Janis)", 362, 96, 192, 124)
$lHost = GUICtrlCreateLabel("Host window:", 10, 10, 68, 17)
$lLeecher = GUICtrlCreateLabel("Leecher window:", 10, 35, 85, 17)
$cHost = GUICtrlCreateCombo("", 110, 6, 241, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
$cLeecher = GUICtrlCreateCombo("", 110, 31, 241, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUICtrlSetOnEvent($cHost, "hostChanged")
GUICtrlSetOnEvent($cLeecher, "leecherChanged")
$bStart = GUICtrlCreateButton("Start", 10, 60, 107, 25)
GUICtrlSetOnEvent($bStart, "Start")
$bRefresh = GUICtrlCreateButton("Refresh windowlist", 130, 60, 107, 25)
GUICtrlSetOnEvent($bRefresh, "refreshList")
$bStop = GUICtrlCreateButton("Stop", 245, 60, 107, 25)
GUICtrlSetOnEvent($bStop, "Stop")
GUICtrlSetState(-1, $GUI_DISABLE)
Dim $Form1_AccelTable[3][2] = [["{F1}", $bStart],["{F3}", $bRefresh],["{F2}", $bStop]]
GUISetAccelerators($Form1_AccelTable)
If $processList[0][0] >= 2 Then
For $i = 1 To $processList[0][0]
_GUICtrlComboBox_AddString($cHost, $processList[$i][1])
_GUICtrlComboBox_AddString($cLeecher, $processList[$i][1])
WinSetTitle(_GetHwndFromPID($processList[$i][1]), "", "Diablo III #" & $processList[$i][1])
Next
EndIf
GUISetState(@SW_SHOW)
GUISetOnEvent($GUI_EVENT_CLOSE, "GUIClose")
Func Worker()
If Not ProcessExists(GUICtrlRead($cHost)) Or Not ProcessExists(GUICtrlRead($cLeecher)) Then
AdlibUnRegister("Worker")
GUICtrlSetState($bStop, $GUI_DISABLE)
GUICtrlSetState($bStart, $GUI_ENABLE)
$status = False
Return
EndIf
; Both accounts must be in game (no moving) to make the script work perfectly!
ErrorConfirm($hostHandle)
FFSnapShot(0, 0, 0, 0, 0, $hostHandle)
If Hex(FFGetPixel(183, 528), 6) = "FFFFFF" Then ; Checks if char is ingame
ControlClick($hostHandle, "", "", "left", 1, 769, 562) ; Open friendlist
SleepRandom()
EndIf
; Invite leecher with host account
ErrorConfirm($hostHandle)
FFSnapShot(0, 0, 0, 0, 0, $hostHandle)
If Hex(FFGetPixel(649, 98), 6) = "1E0D08" Then ; Checks if friendlist is open on host
ControlClick($hostHandle, "", "", "left", 1, 715, 196) ; Clicks on first account party invite on host
SleepRandom(600, 750)
EndIf
; Accept invite with leecher
ErrorConfirm($leecherHandle)
ControlClick($leecherHandle, "", "", "left", 1, 690, 513) ; Accept invite from host at leecher
SleepRandom()
ErrorConfirm($leecherHandle)
FFSnapShot(0, 0, 0, 0, 0, $leecherHandle)
If Hex(FFGetPixel(392, 312), 6) = "1B0A06" Then ; Checks if leave game confirm is open on leecher
ControlClick($leecherHandle, "", "", "left", 1, 335, 351) ; Confirm leave game with "OK" on leecher
SleepRandom()
EndIf
ErrorConfirm($hostHandle)
FFSnapShot(0, 0, 0, 0, 0, $hostHandle)
While Hex(FFGetPixel(716, 197), 6) = "DEB24A" ; Waits until leecher have accepted invite from host
Sleep(100)
WEnd
SleepRandom(2500, 3500)
; Leave party with host account
ErrorConfirm($hostHandle)
ControlClick($hostHandle, "", "", "left", 1, 560, 570) ; Open options window at host
SleepRandom()
ControlClick($hostHandle, "", "", "left", 1, 339, 322) ; Click leave game on host
SleepRandom()
ErrorConfirm($hostHandle)
ControlClick($hostHandle, "", "", "left", 1, 336, 352) ; Confirm leave game with "OK" on host
SleepRandom()
; Leave game with leecher
SleepRandom(1500, 2500)
ErrorConfirm($leecherHandle)
ControlClick($leecherHandle, "", "", "left", 1, 560, 570) ; Open options window at leecher
SleepRandom()
ControlClick($leecherHandle, "", "", "left", 1, 339, 322) ; Click leave game on leecher
SleepRandom()
ErrorConfirm($leecherHandle)
FFSnapShot(0, 0, 0, 0, 0, $leecherHandle)
ControlClick($leecherHandle, "", "", "left", 1, 336, 352) ; Confirm leave game with "OK" on leecher
SleepRandom()
; Start new game at leecher
ErrorConfirm($leecherHandle)
SleepRandom(2500, 3000)
ControlClick($leecherHandle, "", "", "left", 1, 130, 231) ; Click resume game on leecher
; Start new game at host
ErrorConfirm($hostHandle)
ControlClick($hostHandle, "", "", "left", 1, 130, 231) ; Click resume game on host
SleepRandom()
FFSnapShot(0, 0, 0, 0, 0, $leecherHandle)
While Hex(FFGetPixel(183, 528), 6) <> "FFFFFF" ; Waits until leech char is ingame
ControlClick($leecherHandle, "", "", "left", 1, 130, 231)
FFSnapShot(0, 0, 0, 0, 0, $leecherHandle)
ErrorConfirm($leecherHandle)
If Hex(FFGetPixel(681, 560), 6) = "402515" Then
ControlClick($leecherHandle, "", "", "left", 1, 130, 231)
EndIf
Sleep(100)
WEnd
While 1
FFSnapShot(0, 0, 0, 0, 0, $leecherHandle)
$res = FFNearestPixel(10, 5, 0x0038231E)
If $res <> 0 Then
Local $tpoint = DllStructCreate("int X;int Y")
DllStructSetData($tpoint, "X", $res[0])
DllStructSetData($tpoint, "Y", $res[1])
_WinAPI_ClientToScreen($leecherHandle, $tpoint)
$lastHandle = WinGetHandle("[ACTIVE]")
$lastMousePos = MouseGetPos()
If $blockInput Then
BlockInput(1)
EndIf
WinActivate($leecherHandle)
$winPos = WinGetPos($leecherHandle)
MouseMove((DllStructGetData($tpoint, "X") - $winPos[0]), (DllStructGetData($tpoint, "Y") - $winPos[1]))
If $blockInput Then
BlockInput(1)
EndIf
WinActivate($leecherHandle)
MouseClick("left", (DllStructGetData($tpoint, "X") - $winPos[0]), (DllStructGetData($tpoint, "Y") - $winPos[1]), 1)
MouseClick("left", (DllStructGetData($tpoint, "X") - $winPos[0]), (DllStructGetData($tpoint, "Y") - $winPos[1]), 1)
SleepRandom(6000, 8000)
Sleep(400)
If $blockInput Then
BlockInput(0)
EndIf
ExitLoop
EndIf
WEnd
If $resetOldValues Then
WinActivate($lastHandle)
MouseMove($lastMousePos[0], $lastMousePos[1])
EndIf
Sleep(400)
ErrorConfirm($leecherHandle)
ControlClick($leecherHandle, "", "", "left", 1, 573, 442)
SleepRandom(500, 800)
ErrorConfirm($leecherHandle)
ControlClick($leecherHandle, "", "", "left", 1, 573, 442)
SleepRandom(500, 800)
ErrorConfirm($leecherHandle)
ControlClick($leecherHandle, "", "", "left", 1, 573, 442)
ErrorConfirm($leecherHandle)
EndFunc
Func ErrorConfirm($windowHandle)
FFSnapShot(0, 0, 0, 0, 0, $windowHandle)
If Hex(FFGetPixel(476, 350), 6) = "020201" Then ; Checks if options window is opened at host
ControlClick($windowHandle, "", "", "left", 1, 401, 351) ; Click leave game on host
SleepRandom()
Return 1
EndIf
Return 0
EndFunc
Func Start()
If ProcessExists(GUICtrlRead($cHost)) Or GUICtrlRead($cHost) <> "" Then
If ProcessExists(GUICtrlRead($cLeecher)) Or GUICtrlRead($cLeecher) <> "" Then
AdlibRegister("Worker", 2000)
GUICtrlSetState($bStop, $GUI_ENABLE)
GUICtrlSetState($bStart, $GUI_DISABLE)
$status = True
Else
MsgBox(0, "Error", "Selected leecher window was not found.")
EndIf
Else
MsgBox(0, "Error", "Selected host window was not found.")
EndIf
EndFunc
Func SleepRandom($minWait = 700, $maxWait = 800)
Sleep(Random($minWait, $maxWait, 1))
EndFunc
Func Stop()
AdlibUnRegister("Worker")
GUICtrlSetState($bStop, $GUI_DISABLE)
GUICtrlSetState($bStart, $GUI_ENABLE)
$status = False
EndFunc
Func refreshList()
If $status = True Then
AdlibUnRegister("Worker")
GUICtrlSetState($bStop, $GUI_DISABLE)
GUICtrlSetState($bStart, $GUI_ENABLE)
$status = False
EndIf
_GUICtrlComboBox_ResetContent($cHost)
_GUICtrlComboBox_ResetContent($cLeecher)
$processList = ProcessList("Diablo III.exe")
If $processList[0][0] >= 2 Then
For $i = 2 To $processList[0][0]
_GUICtrlComboBox_AddString($cHost, $processList[$i][1])
_GUICtrlComboBox_AddString($cLeecher, $processList[$i][1])
WinSetTitle(_GetHwndFromPID($processList[$i][1]), "", "Diablo III #" & $processList[$i][1])
Next
EndIf
EndFunc
Func hostChanged()
If $status = True Then
AdlibUnRegister("Worker")
GUICtrlSetState($bStop, $GUI_DISABLE)
GUICtrlSetState($bStart, $GUI_ENABLE)
$status = False
EndIf
$hostHandle = _GetHwndFromPID(GUICtrlRead($cHost))
WinMove($hostHandle, "", Default, Default, 800, 600) ; Resize
WinActivate($hostHandle)
$hostInfo = WinGetPos($hostHandle)
MouseClick("left", ($hostInfo[2] - 4), ($hostInfo[3] / 2), 1) ; Resize
EndFunc
Func leecherChanged()
If $status = True Then
AdlibUnRegister("Worker")
GUICtrlSetState($bStop, $GUI_DISABLE)
GUICtrlSetState($bStart, $GUI_ENABLE)
$status = False
EndIf
$leecherHandle = _GetHwndFromPID(GUICtrlRead($cLeecher))
WinMove($leecherHandle, "", Default, Default, 800, 600) ; Resize
WinActivate($leecherHandle)
$leecherInfo = WinGetPos($leecherHandle)
MouseClick("left", ($leecherInfo[2] - 4), ($leecherInfo[3] / 2), 1) ; Resize
EndFunc
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
sleep(100)
WEnd
Func GUIClose()
Exit(1)
EndFunc
Func SimulKey($hWnd, $key, $string = 0, $state = 'skip', $delay = 10)
$user32 = DllOpen('user32.dll')
If $user32 = -1 Then
SetError(-1, 1, -1)
EndIf
Switch StringLower($key)
Case 'enter'
$WM_ENTER = 0x0d
$dCall = DllCall($user32, 'int', "MapVirtualKey", 'int', $WM_ENTER, 'int', 0)
$lParam = BitOR(BitShift($dCall[0], -16), 1)
Case 'space'
$WM_SPACE = 0x20
$dCall = DllCall($user32, 'int', "MapVirtualKey", 'int', $WM_SPACE, 'int', 0)
$lParam = BitOR(BitShift($dCall[0], -16), 1)
Case 'tab'
$WM_TAB = 0x09
$dCall = DllCall($user32, 'int', "MapVirtualKey", 'int', $WM_TAB, 'int', 0)
$lParam = BitOR(BitShift($dCall[0], -16), 1)
Case Else
If $string = 1 Then
$split = StringSplit($key, "")
For $ctn = 1 To $split[0]
$split[$ctn] = Asc(StringLower($split[$ctn]))
Next
For $ctn = 1 To $split[0]
$dCall = DllCall($user32, 'int', "VkKeyScan", 'int', $split[$ctn])
$lParamAsc = DllCall($user32, 'int', "MapVirtualKey", 'int', $dCall[0], 'int', 0)
$lParam = BitOR(BitShift($lParamAsc[0], -16), 1)
$lUpParam = BitOR($lParam, 0xC0000000)
DllCall($user32, 'int', "PostMessage", 'hwnd', $hWnd, 'int', $WM_KEYDOWN, 'int', $dCall[0], 'int', $lParam)
Sleep($delay)
DllCall($user32, 'int', "PostMessage", 'hwnd', $hWnd, 'int', $WM_KEYUP, 'int', $dCall[0], 'int', $lUpParam)
Sleep(100)
Next
ElseIf $string = 0 Then
$key = Asc(StringLower($key))
$dCall = DllCall($user32, 'int', "VkKeyScan", 'int', $key)
$lParamAsc = DllCall($user32, 'int', "MapVirtualKey", 'int', $dCall[0], 'int', 0)
$lParam = BitOR(BitShift($lParamAsc[0], -16), 1)
EndIf
EndSwitch
$lUpParam = BitOR($lParam, 0xC0000000)
If $string = 0 Then
Switch StringLower($state)
Case 'skip'
DllCall($user32, 'int', "PostMessage", 'hwnd', $hWnd, 'int', $WM_KEYDOWN, 'int', $dCall[0], 'int', $lParam)
Sleep($delay)
DllCall($user32, 'int', "PostMessage", 'hwnd', $hWnd, 'int', $WM_KEYUP, 'int', $dCall[0], 'int', $lUpParam)
Case 'down'
DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", $WM_KEYDOWN, "int", $dCall[0], "int", $lParam)
Case 'up'
DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", $WM_KEYUP, "int", $dCall[0], "int", $lParam)
EndSwitch
EndIf
DllClose($user32)
Return 1
EndFunc
Func _GetHwndFromPID($PID)
$hWnd = 0
$winlist = WinList()
Do
For $i = 1 To $winlist[0][0]
If $winlist[$i][0] <> "" Then
$iPID2 = WinGetProcess($winlist[$i][1])
If $iPID2 = $PID Then
$hWnd = $winlist[$i][1]
ExitLoop
EndIf
EndIf
Next
Until $hWnd <> 0
Return $hWnd
EndFunc
Awesome script, works awesome! Already level 10 while writing this!