目标是为英雄联盟创建计时器。它有丛林营地;每个人在杀死它后都会重生。
为此,我想同时为多个计时器激活相同的功能。如果我同时杀死蓝色buff和狼,我想要它们的计时器(单击蓝色魔像的按钮让我的狼获得相同的计时器)。
我没有实现狼按钮,但有一个开始按钮。单击蓝色按钮启动我的计时器,但随后单击开始游戏按钮将其排入队列,直到第一个计时器结束。
我查看了 wiki 页面。但我不想停止正在运行的计时器;我想同时运行另一个。是否存在编码错误、更好的做事方式等?这是我的代码:
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <Timers.au3>
;==> Set our $font variable
Global $font
$font = "Arial Black"
;==> Create our Graphic User Interface
Opt("GUIOnEventMode", 1) ; Change to OnEvent mode
$mainwindow = GUICreate("Jungle Timers Deluxe", 200, 400)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
$startbutton = GUICtrlCreateButton("Start Game", 50, 10, 70)
$ybluebuff = GUICtrlCreateButton("Ancient Golem (Blue)", 10, 40, 50, 50, $BS_MULTILINE)
$yredbuff = GUICtrlCreateButton("Lizard Elder (Red)", 10, 110, 50, 50, $BS_MULTILINE)
$ywraiths = GUICtrlCreateButton("Lizard Elder (Red)", 10, 180, 50, 50, $BS_MULTILINE)
$ywolves = GUICtrlCreateButton("Lizard Elder (Red)", 10, 250, 50, 50, $BS_MULTILINE)
$ydgolems = GUICtrlCreateButton("Lizard Elder (Red)", 10, 320, 50, 50, $BS_MULTILINE)
$ebluebuff = GUICtrlCreateButton("Ancient Golem (Blue)", 100, 40, 50, 50, $BS_MULTILINE)
$eredbuff = GUICtrlCreateButton("Lizard Elder (Red)", 100, 110, 50, 50, $BS_MULTILINE)
$ewraiths = GUICtrlCreateButton("Lizard Elder (Red)", 100, 180, 50, 50, $BS_MULTILINE)
$ewolves = GUICtrlCreateButton("Lizard Elder (Red)", 100, 250, 50, 50, $BS_MULTILINE)
$edgolems = GUICtrlCreateButton("Lizard Elder (Red)", 100, 320, 50, 50, $BS_MULTILINE)
;==> Create our events
GUICtrlSetOnEvent($startbutton, "StartGame")
GUICtrlSetOnEvent($ybluebuff, "yBlueBuff")
;==> Display our Graphic User Interface.
GUISetState(@SW_SHOW)
While 1
Sleep(1000) ; Idle around
WEnd
Func yBlueBuff()
Dim $bluetimer = 10
$i = 1
$ybb = GUICtrlCreateLabel("Your Blue Buff:", 10, 40)
GUICtrlDelete($ybluebuff)
$ybblabel = GUICtrlCreateLabel($i, 15, 60, 50, 40)
While $i <= $bluetimer
GUICtrlDelete($ybblabel)
If $i >= 5 Then
$ybblabel = GUICtrlCreateLabel($i, 15, 60, 50, 40)
GUICtrlSetFont(-1, 22, 500, $font)
GUICtrlSetBkColor($ybblabel, 0xFFCCCC)
$i = $i + 1
ElseIf $i < 5 Then
$ybblabel = GUICtrlCreateLabel($i, 15, 60, 50, 40)
GUICtrlSetFont(-1, 22, 500, $font)
$i = $i + 1
EndIf
Sleep(1000)
WEnd
GUICtrlDelete($ybblabel)
GUICtrlDelete($ybb)
$ybluebuff = GUICtrlCreateButton("Ancient Golem (Blue)", 10, 40, 50, 50, $BS_MULTILINE)
EndFunc ;==>yBlueBuff
Func StartGame()
; Activate your League Window
WinActivate("[CLASS:Notepad]")
; Wait for the Notepad become active - it is titled "Untitled - Notepad" on English systems
WinWaitActive("[CLASS:Notepad]")
; Now that the Notepad window is active type some text
Send("{ENTER}Baron spawns in 15, Dragon spawns at 2:30{ENTER}")
Sleep(500)
Send("{ENTER}Wraiths/Wolves/Double Golems spawn at 1:40. Red & Blue spawn at 1:55{ENTER}")
Sleep(500)
EndFunc ;==>StartGame
Func CLOSEClicked()
;Note: at this point @GUI_CTRLID would equal $GUI_EVENT_CLOSE,
;and @GUI_WINHANDLE would equal $mainwindow
MsgBox(0, "GUI Event", "Thanks for using Jungle Timers Deluxe!")
Exit
EndFunc ;==>CLOSEClicked
; Finished!
我根据记事本示例教程构建了它并使用记事本,因为它更易于调试。