Code:
#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=..\Windows\Microsoft.NET\Framework64\v4.0.30319\SetupCache\Extended\Graphics\stop.ico
#AutoIt3Wrapper_Outfile=Profession_RUN_x86.exe
#AutoIt3Wrapper_Outfile_x64=Y:\Profession_RUN.exe
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Compile_Both=y
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs
AutoIt Version: 3.0
Language: English
Platform: Win xx
Author: RottenMind
Ver. 1.0
Need:
Included:
.Au3 -source
Tested:
CyrealKiller APB1 v. 0.4.2, partial tested.
Problems:
Windows "popup" can cause nerve breakdown!!!
Script Function:
Extend APBInfinity to EXTRA infinity .
Keeps APBi running forever.
HOTKEYS,
Alt+LShift+P, 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
- Add scan so it can be launch multiple ABPi from Root folder and check that all is running
Alert -windows names,
- "Alert", basic gateway not found
#ce
#include-once
#include <array.au3>
Global $Paused, $APBi, $NW, $gameclient, $accounts, $error1, $error2, $error3, $error4
$APBi = "APBInfinite.exe"
$NW = "Neverwinter.exe"
$gameclient = "gameclient.exe"
$NWwin = "Neverwinter"
$APBiWIN = "APB Infinite v0.4.5.0 - by: Cyrealkiller"
$error1 = "Alert"
$error2 = "Microsoft .NET Framework"
$error3 = "nsAppShell:EventWindow"
$error4 = "exception has occurred in your application" ; If you click Continue, the application will ignore this error and attempt to continue. If you click Quit, the application will close immediately. Object reference not set to an instance of an object."
$accounts = IniRead("prayer.ini", "accounts", "counter", "NotFound") ; get account/how many APBPI runs from prayer.ini
HotKeySet("+!p", "TogglePause") ; shift-alt-p, pause key
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
Sleep(30000)
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
Local $waittime
$waittime = IniRead("prayer.ini", "wait", "time", "NotFound") ; sleeptime is random(1000(, 2000(, 1))) x 60 x $waittime
_kill_APBi()
For $counter = 1 To $accounts
Local $path = @ScriptDir & "\APBi_" & $counter & "\" ; .exe location, path
Local $cache = "xulrunner\GeckoFX\Cache\" ; cache location, path
DirRemove($path & $cache, 1) ; delete cache
Sleep(1000)
_RunAPBi()
Next
Sleep(5000)
If WinExists($error3) Then
$waittime = 20
Else
Sleep(500)
EndIf
WinClose($NWwin)
_sleeptime()
Sleep(2000)
WEnd
Func _RunAPBi() ; this must clean up and maybe it need all windows defined by Handel, is Done._
Local $iPID, $hWnd
$iPID = Run($path & $APBi, $path) ; Start AutoProfessionBot, get Program ID from started program
Sleep(20000)
$hWnd = _GetHwndFromPID($iPID) ; Get Windows information from ProgramID
ControlClick($hWnd, "", "[NAME:btnStartBot]", "left", "1") ; Send mouse click to specific window button to start APBi run
Sleep(30000)
If StringInStr(WinGetText($APBiWIN, ""), $error4) Then
ControlClick($hWnd, "", "[CLASS:WindowsForms10.BUTTON.app.0.378734a; INSTANCE:2]", "left", "1") ; Send mouse click to specific window button
Sleep(500)
ControlClick($hWnd, "", "[NAME:btnStopBot]", "left", "1") ; Send mouse click to specific window button to start APBi run
Sleep(5000)
ControlClick($hWnd, "", "[NAME:btnStartBot]", "left", "1") ; Send mouse click to specific window button to start APBi run
Sleep(5000)
EndIf
If WinExists($error2) Then
ControlClick($error2, "", "[CLASS:WindowsForms10.BUTTON.app.0.378734a; INSTANCE:2]", "left", "1") ; Send mouse click to specific window button
Sleep(500)
ControlClick($hWnd, "", "[NAME:btnStopBot]", "left", "1") ; Send mouse click to specific window button to start APBi run
Sleep(5000)
ControlClick($hWnd, "", "[NAME:btnStartBot]", "left", "1") ; Send mouse click to specific window button to start APBi run
Sleep(5000)
EndIf
WinSetState($hWnd, "", @SW_MINIMIZE) ; Obivius, is it?
EndFunc ;==>_RunAPBi
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 _clickthebox()
Sleep(30000)
Local $var = WinList($APBiWIN) ;this makes list for active windows by name
WinClose($error3)
For $i = 1 To $var[0][0] ; we run until list is end
; Only display visble windows that have a title
If $var[$i][0] <> "" And IsVisible($var[$i][1]) Then
$handle = ($var[$i][1])
$title = ($var[$i][0])
WinActivate(HWnd($handle)) ; windows to activate
$iButton = "left" ; Button The Mouse Will Click I.E. "Left Or Right"
$iClicks = "1" ; The Number Of Times To Click
ControlClick($title, "", "[$handle; NAME:btnStopBot]", $iButton, $iClicks) ; Clicking The Window While Its Minmized, controlclick not working, WHY?
Sleep(1000)
ControlClick($title, "", "[$handle; NAME:btnStartBot]", $iButton, $iClicks) ; Clicking The Window While Its Minmized,
Sleep(1000)
EndIf
Next
EndFunc ;==>_clickthebox
Func IsVisible($handle)
If BitAND(WinGetState($handle), 2) Then
Return 1
Else
Return 0
EndIf
EndFunc ;==>IsVisible
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()
Local $randomsleep, $iTimer
$randomsleep = Random(1500, 2000, 1)
$iTimer = TimerInit()
While 1
If TimerDiff($iTimer) >= $waittime * 60 * $randomsleep 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