#include <INet.au3>
#include <Misc.au3>
#include <Date.au3>
Opt("TrayIconHide", 1)
Local $dll = DllOpen("user32.dll")
Local $_wow = "World of Warcraft"
Local $_checkTime = _NowCalc()
Local $_checkInterval = 2
Local $_activeCount = 0
Local $_winActive = WinActive($_wow)
Local $_timeNoSync = _NowCalc()
Local $_noSyncInterval = 300
Local $_timeLog = _NowCalc()
while true
; <!-- WoW -->
if WinActive($_wow) <> $_winActive then
If _DateDiff('s', $_checkTime, _NowCalc()) < $_checkInterval Then
$_activeCount += 1
Else
$_activeCount = 0
EndIf
$_checkTime = _NowCalc()
$_winActive = WinActive($_wow)
EndIf
if ProcessExists("hbrelog.exe") == 0 or (ProcessExists("hbrelog.exe") and ProcessExists("wow.exe") and ProcessExists("honorbuddy.exe")) Then
$_timeNoSync = _NowCalc()
EndIf
Local $_deltaNoSync = _DateDiff('s', $_timeNoSync, _NowCalc())
if $_activeCount >= 10 or (ProcessExists("hbrelog.exe") and $_deltaNoSync >= $_noSyncInterval) Then
if $_activeCount >= 10 then
$_activeCount = 0
EndIf
if ProcessExists("hbrelog.exe") and _DateDiff('s', $_timeNoSync, _NowCalc()) >= $_noSyncInterval Then
$_timeNoSync = _NowCalc()
EndIf
ProcessClose("hbrelog.exe")
ProcessClose("honorbuddy.exe")
ProcessClose("wow.exe")
While ProcessExists("hbrelog.exe") <> 0
Sleep(50)
WEnd
Run("L:\WoW\HB\_HBRelog\hbrelog.exe /autostart")
EndIf
if _IsPressed("72",$dll) AND _IsPressed("12",$dll) then
ProcessClose("hbrelog.exe")
EndIf
; <!-- // WoW -->
WEnd
DllClose($dll)