Code:
#cs
AutoIt Version: 3.0
Language: English
Platform: Win xx
Author: RottenMind
Ver. 3.0
Need:
Included:
.Au3 -source
Tested:
CyrealKiller APB1 v. 0.4.5, tested 2 weeks.
Problems:
Windows "popup" can cause nerve breakdown!!! Use when U are not on PC.
Script Function:
Extend APBInfinity to EXTRA infinity .
Keeps APBi running forever.
HOTKEYS,
PAUSE/Break, pause
Alt+LShift+T, Terminata script
Alt+LShift+D, shows just pop up.
ToDo,(parts exist but need implement properly)
- Add Timer`s instead Sleeep(added)
- Add scan so it can be launch multiple ABPi from Root folder and check that all is running(can be done needed parts found)
#ce
#include-once
#include <array.au3>
Global $Paused, $APBi, $NW, $gameclient
$APBi = "APBInfinite.exe"
$NW = "Neverwinter.exe"
$gameclient = "gameclient.exe"
$NWwin = "Neverwinter"
$accounts = IniRead("prayer.ini", "accounts", "counter", "NotFound") ; get account/how many APBI runs from prayer.ini
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("+!t", "Terminate") ; shift alt t, terminate
HotKeySet("+!d", "ShowMessage") ;Shift-Alt-d vvv
Opt("WinTitleMatchMode", "2") ; Windows extra info
Opt("SendKeyDelay", "50") ; Delays for keys
;;;; Body of program would go here ;;;;
While 1 ; Run Main script, need add Timer to controll and show time to left reStart, need make some error detection from APBi and or Gateway(timer OK, error control NO)
_kill_APBi() ; kills all APBI process
_kill_NWlauncher() ; kills NW game launcher process
_kill_NWclient() ; kills NW gameclient process
For $counter = 1 To $accounts
Local $path = @ScriptDir & "\APBi_" & $counter & "\" ; tels where apbinfinite.exe locate , @SriptDir gives path to script dir
Local $cache = "xulrunner\GeckoFX\Cache\" ; path to Gecko cache
DirRemove($path & $cache, 1) ; clears Gecko cache
Sleep(2000)
_RunAPBi()
Next
Sleep(5000)
For $counter = 1 To $accounts
Local $user = IniRead("prayer.ini", "usernames", "user" & $counter, "NotFound") ; get username from prayer.ini
Local $passwd = IniRead("prayer.ini", "passwords", "user" & $counter, "NotFound") ; get passwd from prayer.ini
Local $path = "\Neverwinter\"
_RunPrayer()
Next
Sleep(5000)
WinClose($NWwin)
Sleep(5000)
_sleeptime()
Sleep(2000)
WEnd
Func _pauseBox()
#region --- CodeWizard generated code Start ---
;MsgBox features: Title=Yes, Text=Yes, Buttons=OK, Icon=None, Timeout=5000 ss
If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer
$iMsgBoxAnswer = MsgBox(0, "mytimeout", "hello we did it cirrictly", 5)
Select
Case $iMsgBoxAnswer = -1 ;Timeout
Case Else ;OK
EndSelect
#endregion --- CodeWizard generated code Start ---
EndFunc ;==>_pauseBox
Func _RunAPBi() ; this must clean up and maybe it need all windows defined by Handel, is Done._
Local $iPID, $hWnd
;If Not ProcessExists($APBi) Then
$iPID = Run($path & $APBi, $path) ; Start AutoProfessionBot, get Program ID from started program
Sleep(15000)
;EndIf
$hWnd = _GetHwndFromPID($iPID) ; Get Windows information from ProgramID
WinActivate($hWnd) ; Activate windows
ControlClick($hWnd, "", "[NAME:btnStartBot]", "left", "1") ; Send mouse click to specific window button to start APBi run
Sleep(45000)
WinSetState($hWnd, "", @SW_MINIMIZE) ; Obivius, is it?
EndFunc ;==>_RunAPBi
Func _RunPrayer()
Local $iPID, $hWnd
$prayring = " 965 146 963" ; pray ring
$mailbox = " 1062 148 1060" ; mailbox
$midllepost = " 1061 146 946" ; midlepost
$near_mailbox = " 1062 148 1060" ; near_maibox
$nav = "/navtoposition"
If Not WinExists($NWwin) Then
Run(@ScriptDir & $path & $NW)
Sleep(20000)
EndIf
;WinClose(HWnd($sHWnd))
Select
Case $counter = 1
$iPID = _Process_getPID($NW)
$hWnd = _GetHwndFromPID($iPID) ; Get Windows information from ProgramID
WinActivate($hWnd) ; Activate windows
ControlSend($hWnd, "", "", "+{TAB}")
Sleep(2000)
ControlSend($hWnd, "", "", "{BS 30}")
Sleep(3000)
ControlSend($hWnd, "", "", $user)
Sleep(3000)
ControlSend($hWnd, "", "", "{TAB}") ;Send("{ENTER}")
Sleep(3000)
ControlSend($hWnd, "", "", $passwd)
Sleep(3000)
ControlSend($hWnd, "", "", "{ENTER}")
Sleep(60000)
MouseClick("LEFT", 278, 130, 2) ;click character Box
Sleep(20000)
Send("u")
Sleep(500)
Send("{ENTER}")
Sleep(2000)
Send($nav & $midllepost) ;midpost "/navtoposition 1061 146 946"
Send("{ENTER}")
Sleep(15000)
Send("{ENTER}")
Sleep(2000)
Send($nav & $prayring) ;prayring
Send("{ENTER}")
Sleep(15000)
Send("{ENTER}")
Sleep(2000)
Send("/invoke")
Sleep(2000)
Send("{ENTER}")
Sleep(2000)
Send("{ENTER}")
Sleep(2000)
Send($nav & $midllepost) ;midpost
Sleep(2000)
Send("{ENTER}")
Sleep(15000)
Send("{ENTER}")
Sleep(2000)
Send($nav & $near_mailbox) ;mailbox
Sleep(2000)
Send("{ENTER}")
Sleep(15000)
; _pauseBox()
WinActivate($NWwin) ; Activate windows
Sleep(2000)
Send("{ENTER}")
Sleep(2000)
Send("/gotoCharacterSelect")
Sleep(2000)
Send("{ENTER}")
Sleep(30000)
MouseClick("LEFT", 285, 202, 2) ;click character box
Sleep(20000)
Send("u")
Sleep(2000)
Send("{ENTER}")
Sleep(2000)
Send($nav & $midllepost) ;midpost
Sleep(2000)
Send("{ENTER}")
Sleep(15000)
Send("{ENTER}")
Sleep(2000)
Send($nav & $prayring) ;prayring
Sleep(2000)
Send("{ENTER}")
Sleep(15000)
Send("{ENTER}")
Sleep(2000)
Send("/invoke")
Sleep(2000)
Send("{ENTER}")
Sleep(2000)
Send("{ENTER}")
Sleep(2000)
Send($nav & $midllepost) ;midpost
Sleep(2000)
Send("{ENTER}")
Sleep(15000)
Send("{ENTER}")
Sleep(2000)
Send($nav & $near_mailbox) ;mailbox
Sleep(2000)
Send("{ENTER}")
Sleep(15000)
; _pauseBox()
WinActivate($NWwin) ; Activate windows
Sleep(2000)
Send("{ENTER}")
Sleep(2000)
Send("/logout")
Sleep(2000)
Send("{ENTER}")
Sleep(30000)
Case $counter = 9
Send("{BS 30}")
Sleep(3000)
Send($user)
Sleep(3000)
Send("{TAB}") ;Send("{ENTER}")
Sleep(3000)
Send($passwd)
Sleep(3000)
Send("{ENTER}")
Sleep(45000)
MouseClick("LEFT", 285, 202, 2)
Sleep(20000)
Send("u")
Sleep(500)
Send("{ENTER}")
Sleep(2000)
Send($nav & $midllepost) ;midpost "/navtoposition 1061 146 946"
Send("{ENTER}")
Sleep(15000)
Send("{ENTER}")
Sleep(2000)
Send($nav & $prayring) ;prayring
Send("{ENTER}")
Sleep(15000)
Send("{ENTER}")
Sleep(2000)
Send("/invoke")
Sleep(2000)
Send("{ENTER}")
Sleep(2000)
Send("{ENTER}")
Sleep(2000)
Send($nav & $midllepost) ;midpost
Sleep(2000)
Send("{ENTER}")
Sleep(15000)
Send("{ENTER}")
Sleep(2000)
Send($nav & $near_mailbox) ;mailbox
Sleep(2000)
Send("{ENTER}")
Sleep(15000)
; _pauseBox()
WinActivate($NWwin) ; Activate windows
Sleep(2000)
Send("{ENTER}")
Sleep(2000)
Send("/logout")
Sleep(2000)
Send("{ENTER}")
Sleep(30000)
Case Else
Send("{BS 30}")
Sleep(3000)
Send($user)
Sleep(3000)
Send("{TAB}") ;Send("{ENTER}")
Sleep(3000)
Send($passwd)
Sleep(3000)
Send("{ENTER}")
Sleep(50000)
MouseClick("LEFT", 278, 130, 2)
Sleep(20000)
Send("u")
Sleep(500)
Send("{ENTER}")
Sleep(2000)
Send($nav & $midllepost) ;midpost "/navtoposition 1061 146 946"
Send("{ENTER}")
Sleep(15000)
Send("{ENTER}")
Sleep(2000)
Send($nav & $prayring) ;prayring
Send("{ENTER}")
Sleep(15000)
Send("{ENTER}")
Sleep(2000)
Send("/invoke")
Sleep(2000)
Send("{ENTER}")
Sleep(2000)
Send("{ENTER}")
Sleep(2000)
Send($nav & $midllepost) ;midpost
Sleep(2000)
Send("{ENTER}")
Sleep(15000)
Send("{ENTER}")
Sleep(2000)
Send($nav & $near_mailbox) ;mailbox
Sleep(2000)
Send("{ENTER}")
Sleep(15000)
; _pauseBox()
WinActivate($NWwin) ; Activate windows
Sleep(2000)
Send("{ENTER}")
Sleep(2000)
Send("/gotoCharacterSelect")
Sleep(2000)
Send("{ENTER}")
Sleep(3000)
MouseClick("LEFT", 285, 202, 2)
Sleep(15000)
Send("u")
Sleep(2000)
Send("{ENTER}")
Sleep(2000)
Send($nav & $midllepost) ;midpost
Sleep(2000)
Send("{ENTER}")
Sleep(20000)
Send("{ENTER}")
Sleep(2000)
Send($nav & $prayring) ;prayring
Sleep(2000)
Send("{ENTER}")
Sleep(15000)
Send("{ENTER}")
Sleep(2000)
Send("/invoke")
Sleep(2000)
Send("{ENTER}")
Sleep(2000)
Send("{ENTER}")
Sleep(2000)
Send($nav & $midllepost) ;midpost
Sleep(2000)
Send("{ENTER}")
Sleep(15000)
Send("{ENTER}")
Sleep(2000)
Send($nav & $near_mailbox) ;mailbox
Sleep(2000)
Send("{ENTER}")
Sleep(15000)
; _pauseBox()
WinActivate($NWwin) ; Activate windows
Sleep(2000)
Send("{ENTER}")
Sleep(2000)
Send("/logout")
Sleep(2000)
Send("{ENTER}")
Sleep(30000)
EndSelect
EndFunc ;==>_RunPrayer
Func _Process_getPID($iPID)
$aProcesslist = ProcessList()
For $i = 1 To $aProcesslist[0][0]
If $aProcesslist[$i][0] = $iPID Then Return $aProcesslist[$i][1]
Next
EndFunc ;==>_Process_getPID
Func _kill_APBi()
While 1 = 1
If ProcessExists($APBi) Then
ProcessClose($APBi)
Sleep(5000)
Else
ExitLoop
EndIf
WEnd
EndFunc ;==>_kill_APBi
Func _kill_NWclient()
While 1 = 1
If ProcessExists($gameclient) Then
ProcessClose($gameclient)
Sleep(5000)
Else
ExitLoop
EndIf
WEnd
EndFunc ;==>_kill_NWclient
Func _kill_NWlauncher()
While 1 = 1
If ProcessExists($NW) Then
ProcessClose($NW)
Sleep(5000)
Else
ExitLoop
EndIf
WEnd
EndFunc ;==>_kill_NWlauncher
Func _sleeptime()
$iTimer = TimerInit()
While 1
If TimerDiff($iTimer) >= 75 * 60 * 1000 Then
While 1 = 1
If ProcessExists($APBi) Then
ProcessClose($APBi)
Sleep(5000)
Else
ExitLoop (2)
EndIf
WEnd
EndIf
Sleep(1000)
WEnd
EndFunc ;==>_sleeptime
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 ;==>_GetHwndFromPID
;;;;;;;;
Func TogglePause()
$Paused = Not $Paused
While $Paused
Sleep(100)
ToolTip('Script is "Paused"', 0, 0)
WEnd
ToolTip("")
EndFunc ;==>TogglePause
Func Terminate()
#region --- CodeWizard generated code Start ---
;MsgBox features: Title=Yes, Text=Yes, Buttons=OK, Icon=Critical, Timeout=5 ss, Miscellaneous=Top-most attribute
If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer
$iMsgBoxAnswer = MsgBox(262160, "Note", "Script is about to Shutdooown.", 5)
Select
Case $iMsgBoxAnswer = -1 ;Timeout
Case Else ;OK
EndSelect
#endregion --- CodeWizard generated code Start ---
Exit 0
EndFunc ;==>Terminate
Func ShowMessage()
MsgBox(4096, "", "Hello Kitty.")
EndFunc ;==>ShowMessage