briancd2 Posted yesterday at 12:44 AM Posted yesterday at 12:44 AM (edited) Not a good coder by any means, but the script works for basic needs. The script takes League of Legend (small server) tournament information (team names, ban picks, etc.) and put that information into a single message to be sent via the webhook as well as create an image grid with the champion bans included in it. It creates the message to send and saves it to my clipboard to paste it to our Discord server myself and it creates the PNG with the champion bans. I want to expedite this process and have the script send the message via the webhook and potentially the image as well if that's possible. The code isn't pretty. Sorry. expandcollapse popup#include <GDIPlus.au3> #include <ScreenCapture.au3> #include <WinAPI.au3> #include <GUIConstantsEx.au3> #include <WinHttp.au3> #include <WindowsConstants.au3> Func Webhook($Message) Local Const $sWebhookURL = "" Local Const $sJsonPayload = '{"content": "' & $Message & '"}' Local $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") If IsObj($oHTTP) Then $oHTTP.Open("POST", $sWebhookURL) $oHTTP.SetRequestHeader("Content-Type", "application/json") $oHTTP.Send($sJsonPayload) If $oHTTP.Status = 204 Then ; 204 No Content indicates success for webhooks MsgBox(0, "Success", "Message sent successfully!") Else MsgBox(0, "Error", "Failed to send message. Status: " & $oHTTP.Status) EndIf Else MsgBox(0, "Error", "Failed to create WinHttp object.") EndIf EndFunc Opt("GUIOnEventMode", 1) Global $t1 = InputBox("Team Name", "What is the first team name?") Global $t2 = InputBox("Team Name", "What is the second team name?") Global $champs = "Aatrox|Ahri|Akali|Akshan|Alistar|Ambessa|Amumu|Anivia|Annie|Ashe|AurelionSol|Aurora|Azir|Bard|Belveth|Blitzcrank|Brand|Braum|Briar|Caitlyn|Camille|Cassiopeia|ChoGath|Corki|Darius|Diana|DrMundo|Draven|Ekko|Elise|Evelynn|Ezreal|Fiddlesticks|Fiora|Fizz|Galio|Gangplank|Garen|Gnar|Gragas|Graves|Gwen|Hecarim|Heimerdinger|Hwei|Illaoi|Irelia|Ivern|Janna|JarvanIV|Jax|Jayce|Jhin|Jinx|Kaisa|Kalista|Karma|Karthus|Kassadin|Katarina|Kayle|Kayn|Kennen|KhaZix|Kindred|Kled|KogMaw|Ksante|Leblanc|LeeSin|Leona|Lillia|Lissandra|Lucian|Lulu|Lux|Malphite|Malzahar|Maokai|MasterYi|Mel|Milio|MissFortune|Mordekaiser|Morgana|Naafiri|Nami|Nasus|Nautilus|Neeko|Nidalee|Nilah|Nocturne|Nunu|Olaf|Orianna|Ornn|Pantheon|Poppy|Pyke|Qiyana|Quinn|Rakan|Rammus|RekSai|Rell|Renata|Renekton|Rengar|Riven|Rumble|Ryze|Samira|Sejuani|Senna|Seraphine|Sett|Shaco|Shen|Shyvana|Singed|Sion|Sivir|Skarner|Smolder|Sona|Soraka|Swain|Sylas|Syndra|TahmKench|Taliyah|Talon|Taric|Teemo|Thresh|Tristana|Trundle|Tryndamere|TwistedFate|Twitch|Udyr|Urgot|Varus|Vayne|Veigar|VelKoz|Vex|Vi|Viego|Viktor|Vladimir|Volibear|Warwick|Wukong|Xayah|Xerath|XinZhao|Yasuo|Yone|Yorick|Yunara|Yuumi|Zac|Zed|Zeri|Ziggs|Zilean|Zoe|Zyra" Global $Message #Region (=== GUI generated by GuiBuilderPlus 1.2.0 ===) Global $hGUI, $GUI Global $Combo_1, $Combo_2, $Combo_3, $Combo_4, $Combo_5, $Combo_6, $Combo_7, $Combo_8, $Combo_9, $Combo_10 Global $Button_1 Func _guiCreate() $hGUI = GUICreate("Tournament Ban Picks", 290, 320, -1, -1) GUISetBkColor(0xC0C0C0) GUISetOnEvent($GUI_EVENT_CLOSE, "_onExitMain") $Label_1 = GUICtrlCreateLabel($t1 & " Bans", 15, 10, 86, 16) $Label_2 = GUICtrlCreateLabel($t2 & " Bans", 160, 10, 86, 16) $Combo_1 = GUICtrlCreateCombo("", 15, 30, 116, 20) GuiCtrlSetData(-1, $champs, "Aatrox") $Combo_2 = GUICtrlCreateCombo("", 15, 70, 116, 20) GuiCtrlSetData(-1, $champs, "Ahri") $Combo_3 = GUICtrlCreateCombo("", 15, 110, 116, 20) GuiCtrlSetData(-1, $champs, "Akali") $Combo_4 = GUICtrlCreateCombo("", 15, 150, 116, 20) GuiCtrlSetData(-1, $champs, "Akshan") $Combo_5 = GUICtrlCreateCombo("", 15, 190, 116, 20) GuiCtrlSetData(-1, $champs, "Alistar") $Combo_6 = GUICtrlCreateCombo("", 160, 30, 116, 20) GuiCtrlSetData(-1, $champs, "Ambessa") $Combo_7 = GUICtrlCreateCombo("", 160, 70, 116, 20) GuiCtrlSetData(-1, $champs, "Amumu") $Combo_8 = GUICtrlCreateCombo("", 160, 150, 116, 20) GuiCtrlSetData(-1, $champs, "Anivia") $Combo_9 = GUICtrlCreateCombo("", 160, 110, 116, 20) GuiCtrlSetData(-1, $champs, "Annie") $Combo_10 = GUICtrlCreateCombo("", 160, 190, 116, 20) GuiCtrlSetData(-1, $champs, "Ashe") $Button_1 = GUICtrlCreateButton("Generate Ban Pool", 70, 245, 151, 41) GUICtrlSetOnEvent($Button_1, "_onButton_1") EndFunc ;==>_guiCreate #EndRegion (=== GUI generated by GuiBuilderPlus 1.2.0 ===) _main() Func _main() _guiCreate() GUISetState(@SW_SHOWNORMAL) While 1 Sleep(100) WEnd EndFunc ;==>_main Func _onExitMain() GUIDelete() Exit EndFunc ;==>_onExitMain Func _onButton_1() GUISetState(@SW_DISABLE, $hGUI) $GUI = GUICreate("BanPool",780,315) Global $bans[10] = [GUICtrlRead($Combo_1), GUICtrlRead($Combo_2), GUICtrlRead($Combo_3), GUICtrlRead($Combo_4), GUICtrlRead($Combo_5), GUICtrlRead($Combo_6), GUICtrlRead($Combo_7), GUICtrlRead($Combo_8), GUICtrlRead($Combo_9), GUICtrlRead($Combo_10)] Local $left = 5 Local $top = 5 Local $u = 0 For $i in $bans $u = $u + 1 _GDIPlus_Startup() $image=_GDIPlus_ImageLoadFromFile("C:\Users\brian\Downloads\champion\" & $i & ".png") _GDIPlus_ImageSaveToFile($image,"image.jpg") _WinAPI_DeleteObject($image) If $u <= 5 Then If $i Then $top = 5 GUICtrlCreatePic("image.jpg", $left, $top) $left = $left + 155 EndIf ElseIf $u >= 6 Then If $u = 6 Then $left = 5 EndIf If $i Then $top = 160 GUICtrlCreatePic("image.jpg", $left, $top) $left = $left + 155 EndIf EndIf Next GUISetState(@SW_SHOWNORMAL, $GUI) GUISetOnEvent($GUI_EVENT_CLOSE, Finish) EndFunc ;==>_onButton_1 Func Finish() FileDelete("C:\Users\brian\Pictures\BanList.png") _ScreenCapture_CaptureWnd ("C:\Users\brian\Pictures\BanList.png", $GUI ,0 ,26 ,-1 ,-1 ,False) _GDIPlus_Shutdown() Webhook("```" & $t1 & " Ban Picks:" & @CRLF & $bans[0] & ", " & $bans[1] & ", " & $bans[2] & ", " & $bans[3] & ", "& $bans[4] & "!```" & @CRLF & "```" & $t2 & " Ban Picks:" & @CRLF & $bans[5] & ", " & $bans[6] & ", " & $bans[7] & ", " & $bans[8] & ", "& $bans[9] & "!```") ClipPut("```" & $t1 & " Ban Picks:" & @CRLF & $bans[0] & ", " & $bans[1] & ", " & $bans[2] & ", " & $bans[3] & ", "& $bans[4] & "!```" & @CRLF & "```" & $t2 & " Ban Picks:" & @CRLF & $bans[5] & ", " & $bans[6] & ", " & $bans[7] & ", " & $bans[8] & ", "& $bans[9] & "!```") GUIDelete($GUI) WinActivate($hGUI) GUISetState(@SW_ENABLE, $hGUI) EndFunc Edited 18 hours ago by briancd2
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now