diff --git a/.gitignore b/.gitignore index b4036e9..ca13033 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ IdleCombos.ahk.bak userdetails.json +redeemcodelog.json idlecombosettings.json idlecombolog.txt +*.exe .vscode/settings.json diff --git a/IdleCombos.ahk b/IdleCombos.ahk index 5a1ad02..6aaaa06 100644 --- a/IdleCombos.ahk +++ b/IdleCombos.ahk @@ -177,6 +177,8 @@ global ZarielFPCurrency := "" global ZarielChallenges := "" global ZarielRequires := "" global ZarielCosts := "" +;Web Tools globals +global WebToolCodes := "https://incendar.com/idlechampions_codes.php#123" ;GUI globals global oMyGUI := "" @@ -739,32 +741,87 @@ Open_Gold: Open_Codes: { + ; GUI MENU + Menu, FileMenu, Add, Auto&Load (Web)`tCtrl+L, Get_Codes_Autoload + Menu, FileMenu, Add, AutoLoad && &Run (Web)`tCtrl+R, Get_Codes_Autoload_Run + Menu, FileMenu, Add, &Submit`tCtrl+S, Redeem_Codes + Menu, EditMenu, Add, Paste`tCtrl+V, Paste + Menu, EditMenu, Add, Delete`tDel, Delete + Menu, HelpMenu, Add, Open &Codes (Web)`tCtrl+O, Open_Web_Codes_Page + Menu, MyMenuBar, Add, &File, :FileMenu + Menu, MyMenuBar, Add, &Edit, :EditMenu + Menu, MyMenuBar, Add, &Help, :HelpMenu + + ; GUI Gui, CodeWindow:New - Gui, CodeWindow:+Resize -MaximizeBox - Gui, CodeWindow:Show, w230 h230, Codes + Gui, Menu, MyMenuBar + Gui, CodeWindow:-Resize -MaximizeBox + Gui, CodeWindow:Show, w230 h240, Codes Gui, CodeWindow:Add, Edit, r12 vCodestoEnter w190 x20 y20, IDLE-CHAM-PION-SNOW Gui, CodeWindow:Add, Button, gRedeem_Codes, Submit Gui, CodeWindow:Add, Button, x+35 gPaste, Paste Gui, CodeWindow:Add, Button, x+35 gClose_Codes, Close - Gui, CodeWindow:Add, Text, w190 x20 y+5 vCodesPending, Codes Pending: 0 + Gui, CodeWindow:Add, Text, w350 x20 y+5 vCodesPending, Codes: 0/1 - Waiting... (1 code per line) return } -Paste: +Paste() { getChestCodes() - GuiControl,, CodestoEnter, %foundCodeString% + loop, parse, foundCodeString, `n, `r + CodeTotal := a_index + GuiControl, , CodestoEnter, %foundCodeString% + GuiControl, , CodesPending, Codes: 0/%CodeTotal% - Waiting... (1 code per line) return - } + } + +Delete() + { + GuiControl, , CodestoEnter, + GuiControl, , CodesPending, Codes: 0/0 - Waiting... (1 code per line) + return + } + +Open_Web_Codes_Page() + { + Run, %WebToolCodes% + return + } + +Get_Codes_Autoload() + { + Open_Web_Codes_Page() + winwait, ALL active IDLE Champions combinationđź”’ codes + sleep, 1000 + send, ^a + clipboard := "" + send, ^c + ClipWait, 1 + if WinExist("IdleCombos") + WinActivate + if WinExist("Redeem Codes") + WinActivate + Paste() + return + } -Redeem_Codes: +Get_Codes_Autoload_Run() + { + Get_Codes_Autoload() + Redeem_Codes() + return + } + +Redeem_Codes() { Gui, CodeWindow:Submit, NoHide - Gui, CodeWindow:Add, Text, x+45, Codes pending: + Gui, CodeWindow:Add, Text, x+45, Codes Remaining: CodeList := StrSplit(CodestoEnter, "`n") CodeCount := CodeList.Length() - CodesPending := "Codes pending: " CodeCount - GuiControl, , CodesPending, % CodesPending, w250 h210 + CodeNum := 1 + CodeTotal := CodeCount + CodesPending := "Codes: " CodeNum "/" CodeTotal " - Starting..." + GuiControl, , CodesPending, % CodesPending, w350 h210 usedcodes := "" someonescodes := "" expiredcodes := "" @@ -863,6 +920,7 @@ Redeem_Codes: } } CodeCount := % (CodeCount-1) + CodeNum := % (CodeTotal-CodeCount) if (CurrentSettings.alwayssavecodes || tempsavesetting) { FileAppend, %sCode%`n, %RedeemCodeLogFile% FileAppend, %rawresults%`n, %RedeemCodeLogFile% @@ -876,17 +934,17 @@ Redeem_Codes: FileAppend, %rawresults%`n, %RedeemCodeLogFile% } } - sleep, 2000 - CodesPending := "Codes pending: " CodeCount - GuiControl, , CodesPending, % CodesPending, w250 h210 + sleep, 1000 + CodesPending := "Codes: " CodeNum "/" CodeTotal " - Submitting..." + GuiControl, , CodesPending, % CodesPending, w350 h210 } - CodesPending := "Codes submitted!" + CodesPending := "Codes: " CodeNum "/" CodeTotal " - Loading Results..." codemessage := "" if !(usedcodes == "") { - codemessage := codemessage "You already used:`n" usedcodes "`n" + codemessage := codemessage "You Already Used:`n" usedcodes "`n" } if !(someonescodes == "") { - codemessage := codemessage "Someone else used:`n" someonescodes "`n" + codemessage := codemessage "Someone Else Has Used:`n" someonescodes "`n" } if !(expiredcodes == "") { codemessage := codemessage "Expired:`n" expiredcodes "`n" @@ -908,7 +966,7 @@ Redeem_Codes: } if !(otherchests == "") { ;StringTrimRight, otherchests, otherchests, 2 - codemessage := codemessage "Other chests:`n" otherchests "`n" + codemessage := codemessage "Other Chests:`n" otherchests "`n" } if (codepolish > 0) { codemessage := codemessage "Potions of Polish:`n" codepolish "`n" @@ -918,15 +976,19 @@ Redeem_Codes: } if !(codeepics == "") { StringTrimRight, codeepics, codeepics, 2 - codemessage := codemessage "Epic consumables:`n" codeepics "`n" + codemessage := codemessage "Epic Consumables:`n" codeepics "`n" } if (codemessage == "") { codemessage := "Unknown or No Results." } - GuiControl, , CodesPending, % CodesPending, w250 h210 + GuiControl, , CodesPending, % CodesPending, w350 h210 GetUserDetails() oMyGUI.Update() - MsgBox, , Results, % codemessage + Gui, CodeWindow: Default + CodesPending := "Codes: " CodeTotal "/" CodeTotal " - Completed!" + GuiControl, , CodesPending, % CodesPending, w350 h210 + ; MsgBox, , Results, % codemessage + ScrollBox(codemessage, "p b1 h200 w250", "Redeem Codes Results") return } @@ -3001,4 +3063,284 @@ while (clipContents ~= regexpPattern) { } foundCodeString := RegExReplace(foundCodeString, "`r`n$") return foundCodeString +} + +;{ ScrollBox +; SOURCE: https://www.autohotkey.com/boards/viewtopic.php?f=6&t=4837 +; AUTHOR: Fanatic Guru +; CHANGELOG: +; 2016 11 18 Version 1.2 +; 2018 06 09 Version 1.21 +; Fixed issue with creating autosize control containing more than 32k characters +; +; FUNCTION to Create Gui Scroll Box +; +;------------------------------------------------ +; +; Method: +; ScrollBox(String, Options, Label) +; +; Parameters: +; 1) {String} String to be displayed in scroll box +; +; 2) {Options} +; d destroy Gui if exist and recreate new +; w word wrap +; p pause until Gui closed +; h hide Gui if exist +; s show Gui if exist +; l left justified +; r right justified +; c center justified +; p%% p followed by a number for ms to pause +; f%% f followed by a number for font size +; f{%%} f followed by font options in format of Gui font command +; x%% x followed by a number for x box location +; y%% y followed by a number for y box location +; h%% h followed by a number for height of box +; w%% w followed by a number for width of box +; t%% t followed by a number for tab stop (can be multiple) +; b1 OK button, pauses for response +; b2 YES / NO buttons, pauses for response +; Options of existing Gui can not be changed except for position and size +; +; 3) {Label} Identifier for dealing with multiply Gui, also the Label at the top of Gui +; Used to create the Gui name, all non-valid characters are striped +; If Label exist and String is null and Options is null then Gui is destroyed +; Otherwise Gui will be updated with new string +; And Options x, y, h, w can be used to reposition and resize Gui Window +; +; If String and Label are null then all Gui are destroyed +; +; Returns: +; 1 OK or YES button pushed +; 0 NO button pushed +; -1 Gui closed or escaped without pushing button +; -2 Gui either had no pause or pause finished causing Gui to close +; +; Global: +; Creates a series of global gui labels prefixed with ScrollBox_Gui_Label_ +; +; Note: +; When scroll box attempts to auto adjust control to fit text it will fail on very large strings. +; If scroll box is given a height and width then larger strings can be displayed. +; Closing the box or hitting escape will destroy the gui. +; +; Example: +; ScrollBox(Text, "w b2 p5000 f{s16 cRed bold, Arial} x50 y50 h400 w400") +; +ScrollBox(String := "", Options := "", Label := "") +{ + Static Gui_List, Gui_Index + DetectHiddenWindows, % (Setting_A_DetectHiddenWindows := A_DetectHiddenWindows) ? "On" : + SetWinDelay, % (Setting_A_WinDelay := A_WinDelay) ? 0 : 0 + if !Gui_List + Gui_List := {} + if Label + { + Gui_Label := "ScrollBox_Gui_Label_" RegExReplace(Label, "i)[^0-9a-z#_@\$]", "") + Gui_Hwnd := Gui_List[Gui_Label] + Win_Hwnd := DllCall("GetParent", UInt, Gui_Hwnd) + if RegExMatch(RegExReplace(Options, "\{.*}"), "i)d") + Gui, %Gui_Label%:Destroy + else if WinExist("ahk_id " Win_Hwnd) + { + if String + GuiControl,,%Gui_Hwnd%, %String% + WinGetPos, WinX, WinY, WinW, WinH + if RegExMatch(Options, "i)x(\d+)", Match) + WinX := Match1 + if RegExMatch(Options, "i)y(\d+)", Match) + WinY := Match1 + if RegExMatch(Options, "i)w(\d+)", Match) + WinW := Match1 + if RegExMatch(Options, "i)h(\d+)", Match) + WinH := Match1 + Winmove, ahk_id %Win_Hwnd%,, WinX, WinY, WinW, WinH + if RegExMatch(Options, "i)h(?!\d)", Match) + Gui, %Gui_Label%:Hide + if RegExMatch(Options, "i)s", Match) + Gui, %Gui_Label%:Show + DetectHiddenWindows, %Setting_A_DetectHiddenWindows% + SetWinDelay, %Setting_A_WinDelay% + return + } + } + else + { + Gui_Index ++ + Gui_Label := "ScrollBox_Gui_Label_" Gui_Index + } + if (!String and !Options) + { + if Label + { + Gui_List.Delete(Gui_Label) + Gui, %Gui_Label%:Destroy + } + else + { + for key, element in Gui_List + Gui, %key%:Destroy + Gui_List := {} + } + DetectHiddenWindows, %Setting_A_DetectHiddenWindows% + SetWinDelay, %Setting_A_WinDelay% + return + } + Gui %Gui_Label%:Default + Gui +LabelAllGui + Adjust1 := 10 + ButtonPushed := -2 + if RegExMatch(Options, "i)f(\d+)", Match) + { + Gui, Font, s%Match1% + Adjust1 := Match1 + } + else if RegExMatch(Options, "i)f\{(.*)}", Match) + { + Options := RegExReplace(Options, "i)f\{.*}") + StringSplit, Match, Match1, `, + Gui, Font, %Match1%, % Trim(Match2) + RegExMatch(Match1, "i)s(\d+)", Adjust) + } + else + Gui, Font + Gui, Margin, 20, 20 + Gui, +MinSize200x200 +Resize + Gui, Color, FFFFFF + Opt := "hwndGui_Hwnd ReadOnly -E0x200 " + if !(Options ~= "i)w(?!\d)") + Opt .= "+0x300000 -wrap " + if RegExMatch(Options, "i)h(\d+)", Match) + Opt .= "h" Match1 " ", Control := true + if RegExMatch(Options, "i)w(\d+)", Match) + Opt .= "w" Match1 " ", Control := true + if (Options ~= "i)c") + Opt .= "center " + if (Options ~= "i)l") + Opt .= "left " + if (Options ~= "i)r") + Opt .= "right " + Loop + { + Pos ++ + if (Pos := RegExMatch(Options, "i)t(\d+)", Match, Pos)) + Opt .= "t" Match1 " " + } until !Pos + Opt_Show := "AutoSize " + if RegExMatch(Options, "i)x(\d+)", Match) + Opt_Show .= "x" Match1 " " + if RegExMatch(Options, "i)y(\d+)", Match) + Opt_Show .= "y" Match1 " " + if Control + { + Gui, Add, Edit, % Opt + GuiControl, , %Gui_Hwnd%, %String% + } + else + { + if (StrLen(String) < 32000) ; Gui control cannot be created with more than 32k of text directly + Gui, Add, Edit, % Opt, %String% + else + { + Gui, Add, Edit, % Opt, % SubStr(String, 1, 32000) + GuiControl, , %Gui_Hwnd%, %String% + } + } + if RegExMatch(Options, "i)b(1|2)", Match) + { + Button := Match1 + if (Button = 1) + Gui, Add, Button, gAllGuiButtonOK hwndScrollBox_Button1_Hwnd Default, OK + else + { + Gui, Add, Button, gAllGuiButtonYES hwndScrollBox_Button1_Hwnd Default, YES + Gui, Add, Button, gAllGuiButtonNO hwndScrollBox_Button2_Hwnd, % " NO " + } + } + Gui, Show, % Opt_Show, % Label ? Label : "ScrollBox" + Gui_List[Gui_Label] := Gui_Hwnd + Win_Hwnd := DllCall("GetParent", UInt, Gui_Hwnd) + WinGetPos,X,Y,W,H, ahk_id %Win_Hwnd% + WinMove, ahk_id %Win_Hwnd%,,X,Y,W-1,H-1 ; Move + WinMove, ahk_id %Win_Hwnd%,,X,Y,W,H ; And Move Back to Force Recalculation of Margins + if Button + ControlSend,,{Tab}{Tab}+{Tab}, ahk_id %Gui_Hwnd% ; Move to Button + else + ControlSend,,^{Home}, ahk_id %Gui_Hwnd% ; Unselect Text and Move to Top of Control + DllCall("HideCaret", "Int", Gui_Hwnd) + if ((Options ~= "i)p(?!\d)") or (!(Options ~= "i)p") and Button)) + while (ButtonPushed = -2) + Sleep 50 + else if RegExMatch(Options, "i)p(\d+)", Match) + { + TimeEnd := A_TickCount + Match1 + while (A_TickCount < TimeEnd and ButtonPushed = -2) + Sleep 50 + Gui_List.Delete(Gui_Label) + Gui, Destroy + } + DetectHiddenWindows, %Setting_A_DetectHiddenWindows% + SetWinDelay, %Setting_A_WinDelay% + Gui, 1:Default + return ButtonPushed + + AllGuiSize: + Resize_Gui_Hwnd := Gui_List[A_Gui] + if Button + { + if (Button = 1) + { + EditWidth := A_GuiWidth - 20 + EditHeight := A_GuiHeight - 20 - (Adjust1 * 3) + ButtonX := EditWidth / 2 - Adjust1 + ButtonY := EditHeight + 20 + (Adjust1/6) + GuiControl, Move, %Resize_Gui_Hwnd%, W%EditWidth% H%EditHeight% + GuiControl, Move, %ScrollBox_Button1_Hwnd%, X%ButtonX% Y%ButtonY% + } + else + { + EditWidth := A_GuiWidth - 20 + EditHeight := A_GuiHeight - 20 - (Adjust1 * 3) + Button1X := EditWidth / 4 - (Adjust1 * 2) + Button2X := 3 * EditWidth / 4 - (Adjust1 * 1.5) + ButtonY := EditHeight + 20 + (Adjust1/6) + GuiControl, Move, %Resize_Gui_Hwnd%, W%EditWidth% H%EditHeight% + GuiControl, Move, %ScrollBox_Button1_Hwnd%, X%Button1X% Y%ButtonY% + GuiControl, Move, %ScrollBox_Button2_Hwnd%, X%Button2X% Y%ButtonY% + } + } + else + { + EditWidth := A_GuiWidth - 20 + EditHeight := A_GuiHeight - 20 + GuiControl, Move, %Resize_Gui_Hwnd%, W%EditWidth% H%EditHeight% + } + return + + AllGuiButtonOK: + ButtonPushed := 1 + Gui, %A_Gui%:Destroy + Gui_List.Delete(A_Gui) + return + + AllGuiButtonYES: + ButtonPushed := 1 + Gui, %A_Gui%:Destroy + Gui_List.Delete(A_Gui) + return + + AllGuiButtonNO: + ButtonPushed := 0 + Gui, %A_Gui%:Destroy + Gui_List.Delete(A_Gui) + return + + AllGuiEscape: + AllGuiClose: + ButtonPushed := -1 + Gui, %A_Gui%:Destroy + Gui_List.Delete(A_Gui) + return } \ No newline at end of file