klanhaboru_main.au3 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. #include <Date.au3>
  2. ConsoleWrite(";; Klanhaboru fun by ChesTeRcs@2023" & @CRLF & @CRLF)
  3. #Region === Configurations
  4. AutoItSetOption("SendKeyDelay", 1)
  5. AutoItSetOption("SendKeyDownDelay", 1)
  6. AutoItSetOption("WinTitleMatchMode", 2)
  7. AutoItSetOption("TrayAutoPause" ,0)
  8. Global $toggleRestoreLastWindow = false ; dont change
  9. Global $browser = IniRead(@ScriptDir & "/config.ini", "Options", "browser", "Google Chrome")
  10. Global $gameTitle = IniRead(@ScriptDir & "/config.ini", "Options", "gameTitle", "Klánháború")
  11. Global $server = IniRead(@ScriptDir & "/config.ini", "Options", "server", "hu83") ; get it from game url
  12. Global $villageId = IniRead(@ScriptDir & "/config.ini", "Options", "villageId", "1") ; get it from game url
  13. Global $scavengeMode = IniRead(@ScriptDir & "/config.ini", "Options", "scavengeMode", "2") ; Mode 0-3 (0-Lusta gyûjtögetõk, 1-Szerény gyûjtögetõk, 2-Okos gyûjtögetõk, 3-Kiváló gyûjtögetõk)
  14. Global $traytip = IniRead(@ScriptDir & "/config.ini", "Options", "trayTip", true)
  15. Global $debug = IniRead(@ScriptDir & "/config.ini", "Options", "debug", false)
  16. Global $gyujtogetesEventTimer = eventStart(0) ; delay task after bot started with seconds (default: 0)
  17. Global $gyujtogetesEventTimer2 = eventStart(0) ; delay task after bot started with seconds (default: 0)
  18. Global $trainUnitsEventTimer = eventStart(3600) ; delay task after bot started with seconds (default: 0)
  19. Global $trainLovassagEventTimer = eventStart(3600) ; delay task after bot started with seconds (default: 0)
  20. Global $trainMachinesEventTimer = eventStart(3600) ; delay task after bot started with seconds (default: 0)
  21. Global $epitesEventTimer = eventStart(0) ; delay task after bot started with seconds (default: 0)
  22. Global $trainKnightEventTimer = eventStart(0) ; delay task after bot started with seconds (default: 0)
  23. Global $sendAttackEventTimer = eventStart(0) ; delay task after bot started with seconds (default: 0)
  24. Global $diamondGatheringEventTimer = eventStart(0) ; delay task after bot started with seconds (default: 0)
  25. Global $pageLoadTime = 400 ; inMs
  26. Global $sleepTimesInEndOfTasks = 2200 ; inMs
  27. #EndRegion
  28. While loopEnd()
  29. ;;;;;;;;;;;;;;;;;;;;;;;;;;; Gyûjtögetés
  30. ;;;;;;;;;;;;;;;;;;;;;;;;;;; sendAll, mode, landzsas, kardforgato, bardos, ijasz, konnyulovas, lovasijasz, nehezlovas, lovag (-1 meant to send all unit button)
  31. $gyujtogetesEventTimer2 = gyujtogetes(false, 2, -1, 0, 0, 0, -1, -1, -1, 0, $gyujtogetesEventTimer2)
  32. $gyujtogetesEventTimer = gyujtogetes(false, 3, 0, 0, 0, 0, -1, -1, -1, 0, $gyujtogetesEventTimer)
  33. ;;;;;;;;;;;;;;;;;;;;;;;;;;; Train Units
  34. $trainUnitsEventTimer = trainUnits( 0, 10, 0, 0, 7200, $trainUnitsEventTimer)
  35. ;;;;;;;;;;;;;;;;;;;;;;;;;;; Train Lovassag
  36. ;;;;;;;;;;;;;;;;;;;;;;;;;;; kem, konnyulovas, lovasijasz, nehezlovas (can be -1 what is meant to all unit button)
  37. $trainLovassagEventTimer = trainLovassag( 0, 0, 0, 0, 3600, $trainLovassagEventTimer)
  38. ;;;;;;;;;;;;;;;;;;;;;;;;;;; Train Machinery
  39. ;;;;;;;;;;;;;;;;;;;;;;;;;;; kos, katapult (can be -1 what is meant to all unit button)
  40. $trainMachinesEventTimer = trainMachines( 0, 0, 3600, $trainMachinesEventTimer)
  41. ;;;;;;;;;;;;;;;;;;;;;;;;;;; Építés
  42. ;;;;;;;;;;;;;;;;;;;;;;;;;;; Options: main, barracks, stable, watchtower, smith, place, statue, market, wood, stone, iron, farm, storage, hide, wall
  43. $epitesEventTimer = epites( "stone", 3600, $epitesEventTimer)
  44. ;;;;;;;;;;;;;;;;;;;;;;;;;;; Train Knight
  45. ;;;;;;;;;;;;;;;;;;;;;;;;;;;
  46. ;$trainKnightEventTimer = trainKnight( 9000, $trainKnightEventTimer)
  47. ;;;;;;;;;;;;;;;;;;;;;;;;;;; Send Attack
  48. ;;;;;;;;;;;;;;;;;;;;;;;;;;; $x, $y, $landzsas, $kardforgato, $bardos, $ijasz, $kem, $konnyulovas, $lovasijasz, $nehezlovas, $kos, $katapult, $lovag, $nemes, $eventTimer
  49. $sendAttackEventTimer = sendAttack(490, 562, 0, 250, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 3750, $sendAttackEventTimer) ; 10800 - 3h
  50. ;;;;;;;;;;;;;;;;;;;;;;;;;;; Diamon Gathering event
  51. ;;;;;;;;;;;;;;;;;;;;;;;;;;;
  52. $diamondGatheringEventTimer = diamondGatheringEvent( $diamondGatheringEventTimer)
  53. WEnd
  54. #Region === Functions
  55. Func loopEnd()
  56. TrayTipGG("")
  57. Sleep(1000)
  58. If ($debug == true) Then ConsoleWrite("should alt tab: " & $toggleRestoreLastWindow & @CRLF)
  59. If ($toggleRestoreLastWindow == true) Then
  60. Send("!{TAB}")
  61. $toggleRestoreLastWindow = false
  62. EndIf
  63. return true
  64. EndFunc
  65. Func diamondGatheringEvent($eventTimer)
  66. If (Not eventTriggered($eventTimer)) Then Return $eventTimer
  67. TraytipGG("Diamong gathering started!" & @CRLF)
  68. openNewTab()
  69. navigateUrl(getGameUrl("event_mine"), false)
  70. sendJsClickById("minecart_action_free")
  71. Sleep($pageLoadTime)
  72. $seconds = parseTimeToSeconds(getDataWithJs("document.getElementById('next_round_countdown').children[0]"))
  73. If ($seconds > 0) Then
  74. $eventTimer = eventStart($seconds)
  75. endTask("Diamong gathering done, next event: " & @CRLF & $eventTimer)
  76. Return $eventTimer
  77. EndIf
  78. endTask("Diamong gathering ERROR!", 3)
  79. Return $eventTimer
  80. EndFunc
  81. Func gyujtogetes($sendAll, $mode, $landzsas, $kardforgato, $bardos, $ijasz, $konnyulovas, $lovasijasz, $nehezlovas, $lovag, $eventTimer) ;Mode 0-3 (0-Lusta gyûjtögetõk, 1-Szerény gyûjtögetõk, 2-Okos gyûjtögetõk, 3-Kiváló gyûjtögetõk)
  82. If ($sendAll = false and $landzsas = 0 and $kardforgato = 0 and $bardos = 0 and $ijasz = 0 and $konnyulovas = 0 and $lovasijasz = 0 and $nehezlovas = 0 and $lovag = 0) Then Return $eventTimer
  83. If (Not eventTriggered($eventTimer)) Then Return $eventTimer
  84. TraytipGG("Gyüjtögetés started!" & @CRLF)
  85. openNewTab()
  86. navigateUrl(getGameUrl("place", "scavenge"), false)
  87. $seconds = parseTimeToSeconds(getDataWithJs("document.getElementsByClassName('scavenge-option')[" & $mode & "].getElementsByClassName('return-countdown')[0]"))
  88. If ($seconds > 0) Then
  89. $eventTimer = eventStart($seconds)
  90. endTask("Gyüjtögetés in progress, next event: " & @CRLF & $eventTimer)
  91. Return $eventTimer
  92. EndIf
  93. If ($sendAll) Then
  94. sendJsClickByClass("fill-all")
  95. Else
  96. sendUnits($landzsas, $kardforgato, $bardos, $ijasz)
  97. sendLovassag(0, $konnyulovas, $lovasijasz, $nehezlovas)
  98. sendRoyalties($lovag, 0)
  99. EndIf
  100. jsExecutor("document.getElementsByClassName('scavenge-option')[" & $mode & "].getElementsByClassName('btn-default')[0].click();")
  101. Sleep($pageLoadTime)
  102. $seconds = parseTimeToSeconds(getDataWithJs("document.getElementsByClassName('scavenge-option')[" & $mode & "].getElementsByClassName('return-countdown')[0]"))
  103. If ($seconds > 0) Then
  104. $eventTimer = eventStart($seconds)
  105. endTask("Gyüjtögetés done, next event: " & @CRLF & $eventTimer)
  106. Return $eventTimer
  107. EndIf
  108. endTask("Gyüjtögetés ERROR!", 3)
  109. Return $eventTimer
  110. EndFunc
  111. Func trainUnits($landzsas, $kardforgato, $bardos, $ijasz, $repeatTimer, $eventTimer)
  112. If ($landzsas = 0 and $kardforgato = 0 and $bardos = 0 and $ijasz = 0) Then Return $eventTimer
  113. If (Not eventTriggered($trainUnitsEventTimer)) Then Return $eventTimer
  114. TraytipGG("Train Units started!" & @CRLF)
  115. openNewTab()
  116. navigateUrl(getGameUrl("barracks"), false)
  117. sendUnits($landzsas, $kardforgato, $bardos, $ijasz)
  118. sendJsClickByClass("btn-recruit")
  119. $eventTimer = eventStart($repeatTimer)
  120. endTask("Train Units done, next event: " & @CRLF & $eventTimer)
  121. Return $eventTimer
  122. EndFunc
  123. Func trainLovassag($kem, $konnyulovas, $lovasijasz, $nehezlovas, $repeatTimer, $eventTimer)
  124. If ($kem = 0 and $konnyulovas = 0 and $lovasijasz = 0 and $nehezlovas = 0) Then Return $eventTimer
  125. If (Not eventTriggered($trainLovassagEventTimer)) Then Return $eventTimer
  126. TraytipGG("Train Lovassag started!" & @CRLF)
  127. openNewTab()
  128. navigateUrl(getGameUrl("stable"), false)
  129. sendLovassag($kem, $konnyulovas, $lovasijasz, $nehezlovas)
  130. sendJsClickByClass("btn-recruit")
  131. $eventTimer = eventStart($repeatTimer)
  132. endTask("Train Lovassag done, next event: " & @CRLF & $eventTimer)
  133. Return $eventTimer
  134. EndFunc
  135. Func trainMachines($kos, $katapult, $repeatTimer, $eventTimer)
  136. If ($kos = 0 and $katapult = 0) Then Return $eventTimer
  137. If (Not eventTriggered($trainMachinesEventTimer)) Then Return $eventTimer
  138. TraytipGG("Train Machines started!" & @CRLF)
  139. openNewTab()
  140. navigateUrl(getGameUrl("garage"), false)
  141. sendMachines($kos, $katapult)
  142. sendJsClickByClass("btn-recruit")
  143. $eventTimer = eventStart($repeatTimer)
  144. endTask("Train Machines done, next event: " & @CRLF & $eventTimer)
  145. Return $eventTimer
  146. EndFunc
  147. Func epites($buildingId, $repeatTimer, $eventTimer) ;Options: main, barracks, stable, watchtower, smith, place, statue, market, wood, stone, iron, farm, storage, hide, wall
  148. If (Not eventTriggered($epitesEventTimer)) Then Return $eventTimer
  149. TraytipGG("Epites started: " & $buildingId & @CRLF)
  150. openNewTab()
  151. navigateUrl(getGameUrl("main"), false)
  152. jsExecutor("document.querySelector('{#}main_buildrow_" & $buildingId & "').querySelector('a.btn-build').click();")
  153. $eventTimer = eventStart($repeatTimer)
  154. endTask("Epites done, next event: " & @CRLF & $eventTimer)
  155. Return $eventTimer
  156. EndFunc
  157. Func trainKnight($repeatTimer, $eventTimer)
  158. If (Not eventTriggered($trainKnightEventTimer)) Then Return $eventTimer
  159. TraytipGG("Train Knight started! " & @CRLF)
  160. openNewTab()
  161. navigateUrl(getGameUrl("statue"), false)
  162. sendJsClickByClass("knight_train_launch")
  163. Sleep($pageLoadTime)
  164. sendJsClickByClass("knight_regimen_confirm")
  165. $eventTimer = eventStart($repeatTimer)
  166. endTask("Train Knight, next event: " & @CRLF & $eventTimer & @CRLF)
  167. Return $eventTimer
  168. EndFunc
  169. Func sendAttack($x, $y, $landzsas, $kardforgato, $bardos, $ijasz, $kem, $konnyulovas, $lovasijasz, $nehezlovas, $kos, $katapult, $lovag, $nemes, $repeatTimer, $eventTimer)
  170. If ($landzsas = 0 and $kardforgato = 0 and $bardos = 0 and $ijasz = 0 and $kem = 0 and $konnyulovas = 0 and $lovasijasz = 0 and $nehezlovas = 0 and $kos = 0 and $katapult = 0 and $lovag = 0 and $nemes = 0) Then Return $eventTimer
  171. If (Not eventTriggered($sendAttackEventTimer)) Then Return $eventTimer
  172. If ($x = null or $y = null) Then Return $eventTimer
  173. TraytipGG("Send Attack started!" & @CRLF)
  174. openNewTab()
  175. navigateUrl(getGameUrl("place", "command"), false)
  176. sendUnits($landzsas, $kardforgato, $bardos, $ijasz)
  177. sendLovassag($kem, $konnyulovas, $lovasijasz, $nehezlovas)
  178. sendMachines($kos, $katapult)
  179. sendRoyalties($lovag, $nemes)
  180. jsExecutor("document.getElementsByClassName('target-input-field')[0].value = '" & $x & "|" & $y & "'")
  181. sendJsClickById("target_attack")
  182. Sleep($pageLoadTime)
  183. sendJsClickById("troop_confirm_submit")
  184. $eventTimer = eventStart($repeatTimer)
  185. endTask("Send Attack done, next event: " & @CRLF & $eventTimer)
  186. Return $eventTimer
  187. EndFunc
  188. Func sendUnits($landzsas, $kardforgato, $bardos, $ijasz)
  189. If ($landzsas > 0) Then jsExecutor("{$}('input[name=spear]').val('" & $landzsas & "').trigger('keyup');")
  190. If ($kardforgato > 0) Then jsExecutor("{$}('input[name=sword]').val('" & $kardforgato & "').trigger('keyup');")
  191. If ($bardos > 0) Then jsExecutor("{$}('input[name=axe]').val('" & $bardos & "').trigger('keyup');")
  192. If ($ijasz > 0) Then jsExecutor("{$}('input[name=archer]').val('" & $ijasz & "').trigger('keyup');")
  193. If ($landzsas < 0) Then jsExecutor("document.getElementsByName('spear')[0].parentElement.lastElementChild.click();")
  194. If ($kardforgato < 0) Then jsExecutor("document.getElementsByName('sword')[0].parentElement.lastElementChild.click();")
  195. If ($bardos < 0) Then jsExecutor("document.getElementsByName('axe')[0].parentElement.lastElementChild.click();")
  196. If ($ijasz < 0) Then jsExecutor("document.getElementsByName('archer')[0].parentElement.lastElementChild.click();")
  197. EndFunc
  198. Func sendLovassag($kem, $konnyulovas, $lovasijasz, $nehezlovas)
  199. If ($kem > 0) Then jsExecutor("{$}('input[name=spy]').val('" & $kem & "').trigger('keyup');")
  200. If ($konnyulovas > 0) Then jsExecutor("{$}('input[name=light]').val('" & $konnyulovas & "').trigger('keyup');")
  201. If ($lovasijasz > 0) Then jsExecutor("{$}('input[name=marcher]').val('" & $lovasijasz & "').trigger('keyup');")
  202. If ($nehezlovas > 0) Then jsExecutor("{$}('input[name=heavy]').val('" & $nehezlovas & "').trigger('keyup');")
  203. If ($kem < 0) Then jsExecutor("document.getElementsByName('spy')[0].parentElement.lastElementChild.click();")
  204. If ($konnyulovas < 0) Then jsExecutor("document.getElementsByName('light')[0].parentElement.lastElementChild.click();")
  205. If ($lovasijasz < 0) Then jsExecutor("document.getElementsByName('marcher')[0].parentElement.lastElementChild.click();")
  206. If ($nehezlovas < 0) Then jsExecutor("document.getElementsByName('heavy')[0].parentElement.lastElementChild.click();")
  207. EndFunc
  208. Func sendMachines($kos, $katapult)
  209. If ($kos > 0) Then jsExecutor("{$}('input[name=ram]').val('" & $kos & "').trigger('keyup');")
  210. If ($katapult > 0) Then jsExecutor("{$}('input[name=catapult]').val('" & $katapult & "').trigger('keyup');")
  211. If ($kos < 0) Then jsExecutor("document.getElementsByName('ram')[0].parentElement.lastElementChild.click();")
  212. If ($katapult < 0) Then jsExecutor("document.getElementsByName('catapult')[0].parentElement.lastElementChild.click();")
  213. EndFunc
  214. Func sendRoyalties($lovag, $nemes)
  215. If ($lovag > 0) Then jsExecutor("{$}('input[name=knight]').val('" & $lovag & "').trigger('keyup');")
  216. If ($nemes > 0) Then jsExecutor("{$}('input[name=snob]').val('" & $nemes & "').trigger('keyup');")
  217. If ($lovag < 0) Then jsExecutor("document.getElementsByName('knight')[0].parentElement.lastElementChild.click();")
  218. If ($nemes < 0) Then jsExecutor("document.getElementsByName('snob')[0].parentElement.lastElementChild.click();")
  219. EndFunc
  220. #EndRegion
  221. #Region === Helper Functions
  222. Func openNewTab()
  223. $hWnd = WinGetHandle("[active]")
  224. $hWndBrowser = WinGetHandle($browser)
  225. if ($hWnd <> $hWndBrowser) Then $toggleRestoreLastWindow = true
  226. WinActivate($browser)
  227. Sleep(10)
  228. Send("^t")
  229. Sleep(10)
  230. EndFunc
  231. Func closeTab()
  232. WinActivate($browser)
  233. Sleep(10)
  234. Send("^w")
  235. Sleep(10)
  236. EndFunc
  237. Func getGameUrl($screen, $mode = "")
  238. $url = "https://" & $server & ".klanhaboru.hu/game.php?village=" & $villageId & "&screen=" & $screen
  239. If (Not ($mode = "")) Then $url &= "&mode=" & $mode
  240. return $url
  241. EndFunc
  242. Func sendJsClickById($elementId)
  243. jsExecutor("document.getElementById('" & $elementId & "').click();")
  244. EndFunc
  245. Func sendJsClickByClass($classId)
  246. jsExecutor("document.getElementsByClassName('" & $classId & "')[0].click();")
  247. EndFunc
  248. Func jsExecutor($code)
  249. navigateUrl("javascript:(function(){{}" & $code & "{}})();")
  250. EndFunc
  251. Func navigateUrl($url, $waitForGame = true)
  252. WinWaitActive($browser)
  253. If ($debug == true) Then TraytipGG($url & @CRLF)
  254. If ($waitForGame) Then WinWaitActive($gameTitle)
  255. Send("^l")
  256. Sleep(10)
  257. Send("^a")
  258. Sleep(10)
  259. Send($url)
  260. Send("{ENTER}")
  261. WinWaitActive($gameTitle) ; now pageLoadTime can be 0
  262. EndFunc
  263. Func getDataWithJs($jsSelector)
  264. $clipBoardCache = ClipGet()
  265. jsExecutor("window.location = '{#}'{+}" & $jsSelector & ".innerHTML")
  266. Send("^l")
  267. Sleep(10)
  268. Send("^a")
  269. Sleep(10)
  270. Send("^c")
  271. Sleep(100)
  272. $data = ClipGet()
  273. ClipPut($clipBoardCache)
  274. $data = StringSplit( $data, "#")
  275. If ($data[0] < 2) Then
  276. If ($debug == true) Then TraytipGG("getDataWithJs error!" & $data & " Expected array size 2, actual: " & $data[0] & @CRLF, 3)
  277. If ($debug == true) Then Sleep(2000)
  278. return ""
  279. EndIf
  280. TraytipGG("Data: " & $data[2] & @CRLF)
  281. return $data[2]
  282. EndFunc
  283. Func parseTimeToSeconds($string)
  284. $parsedString = StringSplit( $string, ":")
  285. If ($parsedString[0] < 3) Then
  286. If ($debug == true) Then TraytipGG("parseTimeToSeconds error! Expected array size 3, actual: " & $parsedString[0] & @CRLF, 3)
  287. If ($debug == true) Then Sleep(2000)
  288. return 0
  289. EndIf
  290. $hours = $parsedString[1]
  291. $minutes = $parsedString[2]
  292. $seconds = $parsedString[3]
  293. return ($hours*3600+$minutes*60+$seconds)
  294. EndFunc
  295. Func TraytipGG($text, $icon = 1, $console = true)
  296. If ($traytip == true) then ToolTip($text, 150, 75, $gameTitle & " - " & $server & " - " & $villageId, $icon)
  297. If ($console == true) then ConsoleWrite($text)
  298. EndFunc
  299. Func endTask($logText, $icon = 1)
  300. TraytipGG($logText & @CRLF, $icon)
  301. ConsoleWrite(@CRLF)
  302. Sleep($sleepTimesInEndOfTasks)
  303. closeTab()
  304. TrayTipGG("")
  305. return true
  306. EndFunc
  307. #EndRegion
  308. #Region === EventHandlers
  309. Func eventStart($secondsToWait = 3, $mode = "s")
  310. return _DateAdd($mode, $secondsToWait, _NowCalc())
  311. EndFunc
  312. Func eventCountDown($targetDate, $mode = "s")
  313. return _DateDiff($mode, _NowCalc(), $targetDate)
  314. EndFunc
  315. Func eventTimePassed($startDate, $targetDate = _NowCalc(), $mode = "s")
  316. return _DateDiff($mode, $startDate, $targetDate)
  317. EndFunc
  318. Func eventTimeCompare($startDate, $targetDate, $mode = "s")
  319. return _DateDiff($mode, $startDate, $targetDate)
  320. EndFunc
  321. Func eventTriggered($targetDate, $mode = "s")
  322. return eventCountDown($targetDate, $mode) <= 0
  323. EndFunc
  324. Func compareTimeEventFormatted($startTime, $endTime = _NowCalc())
  325. $seconds = StringFormat("%02i", Mod(eventTimeCompare($startTime, $endTime, "s"), 60))
  326. $minutes = StringFormat("%02i", Mod(eventTimeCompare($startTime, $endTime, "n"), 60))
  327. $hours = StringFormat("%01i", eventTimeCompare($startTime, $endTime, "h"))
  328. If ($hours <> -1 and $minutes <> -1 and $seconds <> -1) then
  329. return $hours &":" &$minutes &":" &$seconds
  330. Else
  331. EndIf
  332. return ""
  333. EndFunc
  334. Func countdownTimeEventFormatted($endTime)
  335. $seconds = StringFormat("%02i", Mod(eventCountDown($endTime, "s"), 60))
  336. $minutes = StringFormat("%02i", Mod(eventCountDown($endTime, "n"), 60))
  337. $hours = StringFormat("%01i", eventCountDown($endTime, "h"))
  338. If ($hours <> -1 and $minutes <> -1 and $seconds <> -1) then
  339. return $hours &":" &$minutes &":" &$seconds
  340. Else
  341. return ""
  342. EndIf
  343. EndFunc
  344. Func passedTimeEventFormatted($startTime, $endTime = _NowCalc())
  345. $seconds = StringFormat("%02i", Mod(eventTimePassed($startTime, $endTime, "s"), 60))
  346. $minutes = StringFormat("%02i", Mod(eventTimePassed($startTime, $endTime, "n"), 60))
  347. $hours = StringFormat("%01i", eventTimePassed($startTime, $endTime, "h"))
  348. If ($hours <> -1 and $minutes <> -1 and $seconds <> -1) then
  349. return $hours &":" &$minutes &":" &$seconds
  350. Else
  351. return ""
  352. EndIf
  353. EndFunc
  354. #EndRegion