T3RRYT3RR0R

Yahtzee v 1.01b

Jan 11th, 2022 (edited)
1,062
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 72.24 KB | None | 0 0
  1. @Echo off
  2.  
  3. REM test if console is hosted via windows terminal, differentiate between a cmd.exe instance that is a child process of wt.exe
  4. REM bg.exe does not behave as intended when executed from windows terminal.
  5. REM Windows Terminal behaviour       - Does not consistenly flag the release of mouse button click as the end of the input stream.
  6. REM  - expected behavior for cmd.exe - Read mouse input only while mouse button is depressed.
  7. REM impact: Returns input on mouse position change event as well as mouse click event after first click.
  8. REM         The Buttons macro system is designed to act as a script blocking input method and prevent furthor execution
  9. REM         until a click event occurs. In the Windows terminal environment, the button would be deemed as clicked
  10. REM         as soon as the mouse is moved over its location, instead of when the button is clicked.
  11.  Call:TestHost
  12.  If Errorlevel 3 (
  13.   Echo(This script will not work correctly in windows terminal.
  14.   Pause
  15.   Exit /B 1
  16.  )
  17.  
  18. :newGame
  19. CLS
  20.  
  21. REM Yahtzee V 1.0.1 13/01/2022
  22. REM Author: T3RRY
  23. REM
  24. REM Game Rule Variations:
  25. REM Game Comprises of 16 turns, inclusive of Bonus Yahtzees.
  26. REM Bonus Yahtzee's 1 2 and 3 can be used as zero scoring chances.
  27. REM
  28. REM Gameplay:
  29. REM - You may quit the game after any Roll - You will be asked for confirmationation if you select Quit Game.
  30. REM - At the end of each roll:
  31. REM   - Select Keep beneath each dice you wish to keep [Kept dice are remembered between rolls]
  32. REM   - Select Keep All to toggle between All Dice as selected or unselected. Individual dice may subsequently be deselected.
  33. REM   - You may view the state of assigned scores after each roll by clicking View Scoresheet. Any subsequent click will return you to the game.
  34. REM   - Once you are happy with the dice you have selected, if any, Press Continue to proceede to the next roll
  35. REM - After the third roll, you will immediately progress to the scoring sheet screen.
  36. REM   - Assign your score by clicking the scoring option. If the scoring option is valid, it will be assigned without confirmation. This cannot be undone.
  37. REM   - Attempting to assign a score you haven't achieved [Straights, FullHouse, Xkinds etc] will
  38. REM     allow you the option of sacrificing that scoring option [0 score, Confirmation required]
  39. REM   - You must assign a score to progress to the next turn upon Clicking Continue.
  40. REM
  41. REM v 1b modifications:
  42. REM  - Incorporated Highscore saves
  43. REM  - Added basic start menu to allow disabling of rolling animation prior to game start.
  44. REM  - changed virtual terminal verification method
  45. REM
  46. REM May be ADDED in furure:
  47. REM  - Animations for Game Start / Yahtzee / Game Over
  48. REM
  49.  
  50. If "!!"=="" ENDLOCAL
  51. Setlocal EnableExtensions DisableDelayedExpansion
  52.  
  53. REM Start the program from the command line with any argument to disable the Dice roll animations
  54. Set "DisableDelay=%~1"
  55.  
  56. REM The below calls a subscript that will request permission to install BG.exe which is required to facilitate
  57. REM clickable buttons. If permission is denied, or your system is not Virtual Terminal compatible, script will abort.
  58.  Call:Buttons def || (
  59.   Pause
  60.   Endlocal & Goto:Eof
  61.  )
  62.  
  63.  Start /b "" %BG.exe% Play "%WINDIR%\Media\windows unlock.wav"
  64.  
  65.  Set "HighScore=0"
  66.  2> nul > nul (
  67.   More < "%~f0:Highscore.dat" && (
  68.    For /F "usebackq Delims=" %%G in ("%~f0:Highscore.dat")Do Set "HighScore=%%G"
  69.   ) || (
  70.    %bg.exe% play  "%CD%\Windows Print complete.wav"
  71.    (Echo(0) 1>"%~f0:Highscore.dat"
  72.   )
  73.  )
  74.  
  75.  Set "TurnCount=0"
  76.  
  77. REM delay Timing - May not work correctly on NON english based systems [untested].
  78.  For /F "tokens=1,2 delims==" %%G in ('wmic cpu get maxclockspeed /format:value^|%SystemRoot%\System32\Findstr.exe /Li "MaxClockSpeed"')Do Set /A "%%G=%%H" 2> nul
  79.  If not Defined MaxClockSpeed Set "MaxClockSpeed=2000"
  80.  Set /A "DelayBase=(MaxClockSpeed * (Number_Of_Processors*Number_Of_Processors)) - 250","EORdelay=(DelayBase/2)*5"
  81.  
  82. REM macro used to constrain randomized face to an adjacent side within a for loop without Goto.
  83.  Set "ConstrainFlip=Set /A "F#=!Random! %% 6 + 1","1/(Old-F#)",!Side[%%~v]! ||"
  84.  
  85. REM Die FG / BG properties [\E7m inverts]
  86. REM - Virtual terminal variable \E definiton and code page handled within :buttons function
  87.  Set "DB=%\E%[0m%\E%[38;2;;;m%\E%[48;2;200;;m%\E%[7m"
  88.  
  89. REM Die animation macros.
  90. REM Macros used to display static list of rolled dice
  91.   Set "dcol=%\E%[0m%\E%[33;1;7m%\E%[48;2;200;;m" %= Dice background / foreground color =%
  92.   Set "fc=%\E%[48;2;155;;200m☻%dcol%"            %= Dice pip foreground color and character + background reset =%
  93.   Set "d\n=%\E%[1B%\E%[7D"                       %= VT sequences position cursor ready for dices next line =%
  94.   Set "d\e=%\E%[0m%\E%[4A"                %= VT sequences position cursor for next dice [top left] =%
  95.   Set "d1=%\E%C%dcol%╔═════╗%d\n%║     ║%d\n%║  %fc%  ║%d\n%║     ║%d\n%╚═════╝%d\e%"
  96.   Set "d2=%\E%C%dcol%╔═════╗%d\n%%fc%    ║%d\n%║     ║%d\n%║    %fc%%d\n%╚═════╝%d\e%"
  97.   Set "d3=%\E%C%dcol%╔═════╗%d\n%%fc%    ║%d\n%║  %fc%  %dcol%%d\n%║    %fc%%d\n%╚═════╝%d\e%"
  98.   Set "d4=%\E%C%dcol%╔═════╗%d\n%%fc%   %fc%%d\n%║     %dcol%%d\n%%fc%   %fc%%d\n%╚═════╝%d\e%"
  99.   Set "d5=%\E%C%dcol%╔═════╗%d\n%%fc%   %fc%%d\n%║  %fc%  %dcol%%d\n%%fc%   %fc%%d\n%╚═════╝%d\e%"
  100.   Set "d6=%\E%C%dcol%╔═════╗%d\n%%fc%   %fc%%d\n%%fc%   %fc%%d\n%%fc%   %fc%%d\n%╚═════╝%d\e%"
  101. REM Restore cursor;Cusor Down;Cursor left;Save Cursor
  102.   Set "\c=%\E%8%\E%[B%\E%7!DB!"
  103. REM Face Strings, Split via substring every 3rd character to create the 3 lines comprising the die face interior for a given side.
  104.   Set "F1=    ☻    "
  105.   Set "F2=☻       ☻"
  106.   Set "F3=☻   ☻   ☻"
  107.   Set "F4=☻ ☻   ☻ ☻"
  108.   Set "F5=☻ ☻ ☻ ☻ ☻"
  109.   Set "F6=☻ ☻☻ ☻☻ ☻"
  110.  
  111. REM macros used to enforce natural flips of the dice during rolling sequence by excluding opposing side from RNG.
  112.  Set Side[1]="1/(6-F#)"
  113.  Set Side[2]="1/(5-F#)"
  114.  Set Side[3]="1/(4-F#)"
  115.  Set Side[4]="1/(3-F#)"
  116.  Set Side[5]="1/(2-F#)"
  117.  Set Side[6]="1/(1-F#)"
  118.  
  119.  Set "Scored=%\E%[2;11H%\E%[35m !Scored[1]!%\E%[5;11H !Scored[2]!%\E%[8;11H !Scored[3]!%\E%[11;11H !Scored[4]!%\E%[14;11H !Scored[5]!%\E%[17;11H !Scored[6]!"
  120.  Set "Scored=%Scored%%\E%[20;11H !Scored[Yahtzee]!%\E%[2;37H !Scored[ThreeOfAKind]!%\E%[5;37H !Scored[FourOfAKind]!%\E%[8;37H !Scored[FullHouse]!%\E%[11;37H !Scored[SmallStraight]!"
  121.  Set "Scored=%Scored%%\E%[14;37H !Scored[LargeStraight]!%\E%[17;37H !Scored[Chance]!%\E%[20;37H !Scored[BY1]! !Scored[BY2]! !Scored[BY3]!%\E%[0m"
  122.  
  123.  Setlocal EnableDelayedExpansion
  124.  
  125. REM Make.Btn MacroArgs GroupName /S "Button Text" /BG background Color /FG Foreground Color /BO BorderColor /t togglebutton=true  /Y Yposition /X Xposition
  126.  
  127. REM %Make.Btn% Menu /S Start /Y 5
  128. REM %Make.Btn% Menu /S "Disable roll animation" /t
  129.  If defined DisableDelay Set "Btn[Menu][2]{state}=true"
  130.  
  131.  %Make.Btn% Dice /S " Keep" /BG 180 0 0 /FG 0 250 0 /BO 38 2 0 160 120 + 48 2 80 0 120 /t /Y 20 /X 1
  132.  %Make.Btn% Dice /S " Keep" /BG 180 0 0 /FG 0 250 0 /BO 38 2 0 160 120 + 48 2 80 0 120 /t /Y 20 /X 8
  133.  %Make.Btn% Dice /S " Keep" /BG 180 0 0 /FG 0 250 0 /BO 38 2 0 160 120 + 48 2 80 0 120 /t /Y 20 /X 15
  134.  %Make.Btn% Dice /S " Keep" /BG 180 0 0 /FG 0 250 0 /BO 38 2 0 160 120 + 48 2 80 0 120 /t /Y 20 /X 22
  135.  %Make.Btn% Dice /S " Keep" /BG 180 0 0 /FG 0 250 0 /BO 38 2 0 160 120 + 48 2 80 0 120 /t /Y 20 /X 29
  136.  
  137.  %Make.Btn% KeepAll /S "Keep All Dice" /BG 180 0 0 /FG 0 250 0 /BO 38 2 0 160 120 + 48 2 80 0 120 /t /Y 23 /X 11
  138.  %Make.Btn% Control /S "Continue" /BG 0 90 120 /FG 255 255 255 /Y 23 /X 1
  139.  %Make.Btn% Control /S "Quit Game" /BG 150 0 120 /FG 255 255 255 /Y 23 /X 26
  140.  %Make.btn% Control /S ? /Y 23 /X 37 /t /d
  141.  %Make.Btn% ScoreSheet /S "         View ScoreSheet            " /BG 150 0 120 /FG 255 255 255 /Y 26 /X 1
  142.  %Make.Btn% Hold /S "            Continue                " /BG 0 90 120 /FG 255 255 255 /Y 26 /X 1
  143.  
  144.  %Make.btn% Scoring /S "    Ones" /Y 2 /X 1 /N /T
  145.  %Make.btn% Scoring /S "    Twos" /T
  146.  %Make.btn% Scoring /S "  Threes" /T
  147.  %Make.btn% Scoring /S "   Fours" /T
  148.  %Make.btn% Scoring /S "   Fives" /T
  149.  %Make.btn% Scoring /S "   Sixes" /T
  150.  %Make.btn% Scoring /S "Three of a Kind" /Y 2 /X 20 /T
  151.  %Make.btn% Scoring /S " Four of A Kind" /X 20 /T
  152.  %Make.btn% Scoring /S "     Full House" /X 20 /T
  153.  %Make.btn% Scoring /S " Small Straight" /X 20 /T
  154.  %Make.btn% Scoring /S " Large Straight" /X 20 /T
  155.  %Make.btn% Scoring /S "         Chance" /X 20 /T
  156.  %Make.btn% Scoring /S " Yahtzee" /X 1 /T
  157.  %Make.btn% Scoring /S "BY1" /Y 20 /X 20 /T
  158.  %Make.btn% Scoring /S "BY2" /Y 20 /X 25 /T
  159.  %Make.btn% Scoring /S "  BY3" /Y 20 /X 30 /T
  160.  
  161.  Set "BG=%\E%[7m%\E%[1;1H%\E%[48;2;;;120m%\E%[K"
  162.  For /L %%i in (2 1 12)Do Set "BG=!BG!%\E%[1E%\E%[48;2;40;80;0m%\E%[K"
  163.  Set "BG=!BG!%\E%[1E%\E%[48;2;;;120m%\E%[K"
  164.  
  165. :StartMenu
  166. REM %Get.Click% Menu
  167. REM %If.btn[Menu]%[1] Goto:Turn
  168. REM %If.btn[Menu]%[2] (
  169. REM  if "!Btn[Menu][2]{state}!"=="true" (
  170. REM   Set "DisableDelay=true"
  171. REM  )Else Set "DisableDelay="
  172. REM )
  173. REM Goto:StartMenu
  174.  
  175.  Call:YesNo "Animation Disabled" "Normal Mode" "Welcome^!"
  176.  If "!Clicked[YN]!"=="Normal Mode" Goto:Turn
  177.  Set "DisableDelay=true"
  178.  
  179. :Turn
  180.  If defined DisableDelay Set "Btn[Control][3]{state}=false"
  181.  cls
  182.  Mode 180,40
  183.  Set "RollCount=0"
  184.  If !TurnCount! EQU 16 (
  185.   Set /A Upperscore=TotalScore=Scored[UpperBonus]=0
  186.   For /l %%i in (1 1 6)Do Set /A "Upperscore+=Scored[%%i]"
  187.   If !UpperScore! GEQ 63 Set "Scored[UpperBonus]=35"
  188.   For /f "tokens=2 Delims==" %%G in ('Set Scored[')Do Set /A "TotalScore+=%%G"
  189.   Set /A "LowerScore=TotalScore-UpperScore-Scored[UpperBonus]"
  190.   If !TotalScore! GTR !HighScore! (
  191.    (Echo(!TotalScore!) 1>"%~f0:Highscore.dat"
  192.    %bg.exe% play "%Windir%\Media\Windows Print complete.wav"
  193.    Title New HighScore: !TotalScore!
  194.   )
  195.   CLS
  196.   Echo( %\E%[0m%\E%[31m%\E%[7m%\E%[K Your Score:%\E%[33m
  197.   Echo( Upper:%\E%[32m!UpperScore!%\E%[33m UpperBonus:%\E%[32m!Scored[UpperBonus]!%\E%[33m Lower:%\E%[32m!LowerScore! %\E%[33mTotal:%\E%[32m!TotalScore!%\E%[0m%\E%[1E
  198.   Timeout /T 5
  199.   Call:yesNo "Play Agian" "Quit" "Game Over"
  200.   If Errorlevel 2 (
  201.    Endlocal & Endlocal
  202.    Exit /b 0
  203.   )
  204.   Endlocal & Endlocal & Set "DisableDelay=%DisableDelay%"
  205.   Goto:NewGame
  206.  )
  207.  
  208. (For /F "tokens=1,2 Delims==" %%G in ('Set "Roll["')Do Set "%%G=") 2> nul
  209.  Call :#Rolls 5
  210.  Set /A #StdOut=1
  211.  Call:DiceSelect || (Endlocal & Exit /b)
  212.  If not !Kept! EQU 5 Call :SortRolls Roll Roll[i] !$Roll! !nDice!
  213.  If not !Kept! EQU 5 Call :#Rolls 5
  214.  If not !Kept! EQU 5 Call:DiceSelect || (Endlocal & Exit /b)
  215.  If not !Kept! EQU 5 Call :SortRolls Roll Roll[i] !$Roll! !nDice!
  216.  If not !Kept! EQU 5 Call :#Rolls 5
  217.  If not !Kept! EQU 5 Call :SortRolls Roll Roll[i] !$Roll!
  218.  If not !Kept! EQU 5 Call :SortRolls Roll Roll[i] !$Roll!
  219.  Call:TestRoll
  220.  Set /A "TurnCount+=1"
  221.  
  222.  For /l %%i in (1 1 5)Do Set "Btn[dice][%%i]{state}=false")
  223.  
  224. Goto:Turn
  225.  
  226. REM Script Break
  227.  
  228. :DiceSelect =========================== Button Menu Logic for dice retention
  229.  Set "nDice="
  230.  Set "Btn[KeepAll][1]{state}=false"
  231.  
  232.  :KeepX
  233.  If "!btn[Control][3]{state}!"=="false" (
  234.   Set "DisableDelay=true"
  235.  )Else Set "DisableDelay="
  236.  
  237.  Set "Kept=0"
  238.  %Get.Click% Dice Control KeepAll ScoreSheet
  239.  If "!Group!" == "ScoreSheet" (
  240.   %Buffer:@=Alt%
  241.   For /l %%i in (1 1 16)Do If "!Btn[Scoring][%%i]{state}!"=="true" (
  242.    set "tmpstr=!Btn[Scoring][%%i]:38=7;38!"
  243.    <nul set /P "=!tmpstr:48=7;48!"
  244.   )Else Echo(!Btn[Scoring][%%i]!
  245.   Echo(%Scored%
  246.   %Get.Click% Hold
  247.   %Buffer:@=Main%
  248.  )Else IF "!Group!" == "KeepAll" (
  249.   For /L %%i in (1 1 5)Do If "!Btn[KeepAll][1]{state}!"=="true" (
  250.    Set "Btn[Dice][%%i]{state}=true
  251.   )Else (
  252.    Set "Btn[Dice][%%i]{state}=false"
  253.   )
  254.  )Else IF "!Group!" == "Control" (
  255.   %If.Btn[Control]%[3] Goto:KeepX
  256.   %If.Btn[Control]%[2] (
  257.    Call:YesNo Quit Return "Are you Sure?"
  258.    If /I "!Clicked[YN]!"=="Quit" Exit /B 1
  259.    Goto:KeepX
  260.   )
  261.   For /l %%i in (1 1 5)Do (
  262.    If "!btn[Dice][%%i]{state}!"=="false" (
  263.     Set "Roll[%%i]="
  264.    )Else (
  265.     Set /A "Kept+=1"
  266.     If defined nDice (
  267.      Set "nDice=!nDice! !Roll[%%i]!"
  268.     )Else (
  269.      Set "nDice=!Roll[%%i]!"
  270.     )
  271.    )
  272.   )
  273.   Exit /B 0
  274.  )
  275.  Goto:KeepX
  276.  
  277. Exit /b 0
  278.  
  279. :TestRoll ======================== Assess Roll outcomes and define scoring array
  280.  
  281.  Set /A "Chance[score]=Roll[1]+Roll[2]+Roll[3]+Roll[4]+Roll[5]","ThreeOfAKind[Score]=Chance[score]","FourOfAKind[Score]=Chance[score]","FullHouse[Score]=25","Yahtzee[score]=50"
  282.  Set /A "SmallStraight[score]=30","LargeStraight[score]=40"
  283.  Set "Scoreset=!Roll[1]!!Roll[2]!!Roll[3]!!Roll[4]!!Roll[5]!"
  284.  
  285.  Set "[1][score]=0"
  286.  Set "null=%Scoreset:1="& Set /A "[1][score]+=1" & Set "null=%"
  287.  Set "[2][score]=0"
  288.  Set "null=%Scoreset:2="& Set /A "[2][score]+=2" & Set "null=%"
  289.  Set "[3][score]=0"
  290.  Set "null=%Scoreset:3="& Set /A "[3][score]+=3" & Set "null=%"
  291.  Set "[4][score]=0"
  292.  Set "null=%Scoreset:4="& Set /A "[4][score]+=4" & Set "null=%"
  293.  Set "[5][score]=0"
  294.  Set "null=%Scoreset:5="& Set /A "[5][score]+=5" & Set "null=%"
  295.  Set "[6][score]=0"
  296.  Set "null=%Scoreset:6="& Set /A "[6][score]+=6" & Set "null=%"
  297.  
  298.  Set "Yahtzee=false"
  299.  Set "Fullhouse=false"
  300.  Set "ThreeOfAKind=false"
  301.  Set "FourOfAKind=false"
  302.  
  303.  For /l %%1 in (1 1 6)Do For /L %%2 in (1 1 6)Do (
  304.   For %%G in ("%%1%%1%%1%%2%%2" "%%1%%1%%2%%2%%2")Do if "%%~G" == "!Roll[1]!!Roll[2]!!Roll[3]!!Roll[4]!!Roll[5]!" (
  305.    Set "ThreeOfAKind=true"
  306.    if not "%%1"=="%%2" (
  307.     Set "FullHouse=true"
  308.    )Else (
  309.     Set "Yahtzee=true"
  310.     Set "FourOfAKind=true"
  311.  )))
  312.  
  313.  If not "!FourOfAKind!"=="true" For /l %%1 in (1 1 6)Do For /L %%2 in (1 1 6)Do if not "%%1"=="%%2" (
  314.   For %%G in ("%%1%%1%%1%%1%%2" "%%2%%1%%1%%1%%1")Do if "%%~G" == "!Roll[1]!!Roll[2]!!Roll[3]!!Roll[4]!!Roll[5]!" (
  315.    Set "FourOfAKind=true"
  316.    Set "ThreeOfAKind=true"
  317.  ))
  318.  
  319.  If not "!ThreeOfAKind!"=="true" For /l %%1 in (1 1 6)Do (
  320.   For %%G in (".%%1%%1%%1." "..%%1%%1%%1" "%%1%%1%%1..")Do For %%H in ("!Roll[1]!!Roll[2]!!Roll[3]!" "!Roll[2]!!Roll[3]!!Roll[4]!" "!Roll[3]!!Roll[4]!!Roll[5]!")Do (
  321.    if "%%~G" == ".%%~H." (
  322.     Set "ThreeOfAKind=true"
  323.    )
  324.    if "%%~G" == "..%%~H" (
  325.     Set "ThreeOfAKind=true"
  326.    )
  327.    if "%%~G" == "%%~H.." (
  328.     Set "ThreeOfAKind=true"
  329.  )))
  330.  
  331.  Set "LargeStraight=false"
  332.  Set "SmallStraight=false"
  333.  For %%G in (12345 23456)Do if "%%G" == "!Roll[1]!!Roll[2]!!Roll[3]!!Roll[4]!!Roll[5]!" (
  334.   Set "LargeStraight=true"
  335.   Set "SmallStraight=true"
  336.  )
  337.  
  338.  
  339.  If not "!SmallStraight!"=="true" For %%G in (11234 12234 12334 12344 12346 13456 22345 23345 23445 23455 33456 34456 34556 34566)Do (
  340.   if "%%G" == "!Roll[1]!!Roll[2]!!Roll[3]!!Roll[4]!!Roll[5]!" (
  341.    Set "SmallStraight=true"
  342.  ))
  343.  
  344. =========================================================== REM score Assignment via button input
  345.  Set "ScoreAssigned="
  346.  :ScoreMenu
  347.  Cls
  348.  Echo(%Scored%
  349.  
  350.  Echo(%\E%[28;1H
  351.  For /L %%i in (1 1 5)Do For %%v in (!Roll[%%i]!)Do <nul Set /p"=!d%%v!"
  352.  Echo(%\E%[1;1H
  353.  %Get.Click% Scoring Hold
  354.  If "!Group!"=="Hold" (
  355.   If Defined ScoreAssigned (
  356.     Exit /B 0
  357.   )Else (
  358.    Start /b "" %BG.exe% play "%WINDIR%\Media\Windows Error.wav"
  359.    Goto:ScoreMenu
  360.   )
  361.  )
  362.  
  363.  For /l %%i in (1 1 6)Do %If.Btn[Scoring]%[%%i] (
  364.   Set "Btn[Scoring][%%i]{state}=false"
  365.   If not defined ScoreAssigned (
  366.    If not defined Scored[%%i] (
  367.     Set /A Scored[%%i]=[%%i][Score],ScoreAssigned=1
  368.   ))
  369.   If defined Scored[%%i] Set "Btn[Scoring][%%i]{state}=true"
  370.  )
  371.  
  372.  %If.Btn[Scoring]%[7] (
  373.   Set "Btn[Scoring][7]{state}=false"
  374.   If not defined ScoreAssigned (
  375.    If "!ThreeOfAKind!"=="true" (
  376.     If not defined Scored[ThreeOfAKind] (
  377.      Set /A Scored[ThreeOfAKind]=ThreeOfAKind[Score],ScoreAssigned=1
  378.     )
  379.    )Else If not defined Scored[ThreeOfAKind] (
  380.     Call :YesNo Yes No "Sacrifice Three of a Kind?"
  381.     If /I "!Clicked[YN]!" == "Yes" Set /A "Scored[ThreeOfAKind]=0",ScoreAssigned=1
  382.    )
  383.   )
  384.   If defined Scored[ThreeOfAKind] Set "Btn[Scoring][7]{state}=true"
  385.  )
  386.  
  387.  %If.Btn[Scoring]%[8] (
  388.   Set "Btn[Scoring][8]{state}=false"
  389.   If not defined ScoreAssigned (
  390.    If "!FourOfAKind!"=="true" (
  391.     If not defined Scored[FourOfAKind] (
  392.      Set /A Scored[FourOfAKind]=FourOfAKind[Score],ScoreAssigned=1
  393.     )
  394.    )Else If not defined Scored[FourOfAKind] (
  395.     Call :YesNo Yes No "Sacrifice Four of a Kind?"
  396.     If /I "!Clicked[YN]!" == "Yes" Set /A "Scored[FourOfAKind]=0",ScoreAssigned=1
  397.    )
  398.   )
  399.   If defined Scored[FourOfAKind] Set "Btn[Scoring][8]{state}=true"
  400.  )
  401.  
  402.  %If.Btn[Scoring]%[9] (
  403.   Set "Btn[Scoring][9]{state}=false"
  404.   If not defined ScoreAssigned (
  405.    If "!FullHouse!"=="true" (
  406.     If not defined Scored[FullHouse] (
  407.      Set /A Scored[FullHouse]=FUllHouse[Score],ScoreAssigned=1
  408.     )
  409.    )Else If not defined Scored[FullHouse] (
  410.     Call :YesNo Yes No "Sacrifice Fullhouse?"
  411.     If /I "!Clicked[YN]!" == "Yes" Set /A "Scored[FullHouse]=0",ScoreAssigned=1
  412.    )
  413.   )
  414.   If defined Scored[FullHouse] Set "Btn[Scoring][9]{state}=true"
  415.  )
  416.  
  417.  %If.Btn[Scoring]%[10] (
  418.   If not defined Scored[SmallStraight] Set "Btn[Scoring][10]{state}=false"
  419.   If not defined ScoreAssigned (
  420.    If "!SmallStraight!"=="true" (
  421.     If not defined Scored[SmallStraight] (
  422.      Set /A Scored[SmallStraight]=Smallstraight[Score],ScoreAssigned=1
  423.     )
  424.    )Else If not defined Scored[SmallStraight] (
  425.     Call :YesNo Yes No "Sacrifice Small Straight?"
  426.     If /I "!Clicked[YN]!" == "Yes" Set /A "Scored[SmallStraight]=0",ScoreAssigned=1
  427.    )
  428.   )
  429.   If defined Scored[SmallStraight] Set "Btn[Scoring][10]{state}=true"
  430.  )
  431.  
  432.  %If.Btn[Scoring]%[11] (
  433.   If not defined Scored[LargeStraight] Set "Btn[Scoring][11]{state}=false"
  434.   If not defined ScoreAssigned (
  435.    If "!LargeStraight!"=="true" (
  436.     If not defined Scored[LargeStraight] (
  437.      Set /A Scored[LargeStraight]=LargeStraight[Score],ScoreAssigned=1
  438.     )
  439.    )Else If not defined Scored[LargeStraight] (
  440.     Call :YesNo Yes No "Sacrifice Large Straight?"
  441.     If /I "!Clicked[YN]!" == "Yes" Set /A "Scored[LargeStraight]=0",ScoreAssigned=1
  442.    )
  443.   )
  444.   If defined Scored[LargeStraight] Set "Btn[Scoring][11]{state}=true"
  445.  )
  446.  
  447.  %If.Btn[Scoring]%[12] (
  448.   Set "Btn[Scoring][12]{state}=false"
  449.   If not defined ScoreAssigned (
  450.    If not defined Scored[Chance] (
  451.     Set /A Scored[Chance]=Chance[Score],ScoreAssigned=1
  452.   ))
  453.   If defined Scored[Chance] Set "Btn[Scoring][12]{state}=true"
  454.  )
  455.  
  456.  %If.Btn[Scoring]%[13] (
  457.   Set "Btn[Scoring][13]{state}=false"
  458.   If not defined ScoreAssigned (
  459.    If "!Yahtzee!"=="true" (
  460.     If not defined Scored[Yahtzee] (
  461.      Set /A Scored[Yahtzee]=Yahtzee[Score],ScoreAssigned=1
  462.     )
  463.    )Else If not defined Scored[Yahtzee] (
  464.     Call :YesNo Yes No "Sacrifice Yahtzee?"
  465.     If /I "!Clicked[YN]!" == "Yes" Set /A "Scored[Yahtzee]=0",ScoreAssigned=1
  466.    )
  467.   )
  468.   If defined Scored[Yahtzee] Set "Btn[Scoring][13]{state}=true"
  469.  )
  470.  
  471.  %If.Btn[Scoring]%[14] (
  472.   Set "Btn[Scoring][14]{state}=false"
  473.   If not defined ScoreAssigned (
  474.    If "!Yahtzee!"=="true" (
  475.     If defined Scored[Yahtzee] If not defined Scored[BY1] (
  476.      Set /A "Scored[BY1]=Scored[Yahtzee]*2",ScoreAssigned=1
  477.     )
  478.    )Else If not defined Scored[BY1] (
  479.     Call :YesNo Yes No "Sacrifice Bonus Yahtzee 1?"
  480.     If /I "!Clicked[YN]!" == "Yes" Set /A "Scored[BY1]=0",ScoreAssigned=1
  481.    )
  482.   )
  483.   If defined Scored[BY1] Set "Btn[Scoring][14]{state}=true"
  484.  )
  485.  
  486.  %If.Btn[Scoring]%[15] (
  487.   Set "Btn[Scoring][15]{state}=false"
  488.   If not defined ScoreAssigned (
  489.    If "!Yahtzee!"=="true" (
  490.     If defined Scored[Yahtzee] If not defined Scored[BY2] (
  491.      Set /A "Scored[BY2]=Scored[Yahtzee]*2",ScoreAssigned=1
  492.     )
  493.    )Else If Defined Scored[BY1] If not defined Scored[BY2] (
  494.     Call :YesNo Yes No "Sacrifice Bonus Yahtzee 2?"
  495.     If /I "!Clicked[YN]!" == "Yes" Set /A "Scored[BY2]=0",ScoreAssigned=1
  496.    )
  497.   )
  498.   If defined Scored[BY2] Set "Btn[Scoring][15]{state}=true"
  499.  )
  500.  
  501.  %If.Btn[Scoring]%[16] (
  502.   Set "Btn[Scoring][16]{state}=false"
  503.   If not defined ScoreAssigned (
  504.    If "!Yahtzee!"=="true" (
  505.     If defined Scored[Yahtzee] If not defined Scored[BY3] (
  506.      Set /A "Scored[BY3]=Scored[Yahtzee]*2",ScoreAssigned=1
  507.     )
  508.    )Else If Defined Scored[BY2] If not defined Scored[BY3] (
  509.     Call :YesNo Yes No "Sacrifice Bonus Yahtzee 3?"
  510.     If /I "!Clicked[YN]!" == "Yes" Set /A "Scored[BY3]=0",ScoreAssigned=1
  511.    )
  512.   )
  513.   If defined Scored[BY3] Set "Btn[Scoring][16]{state}=true"
  514.  )
  515.  
  516. Goto:ScoreMenu
  517.  
  518. :SortRolls ======================= <Element_VarName> <Element_Index_VarName>
  519.  Set /a "Max=%2+1"
  520.  For /L %%a In (0,1,!Max!)Do (
  521.   Set /A "S_Offset=%%a - 1"
  522.   For /L %%b IN (0,1,%%a)Do (
  523.    If not %%b==%%a For %%c in (!S_Offset!)Do (
  524.     If defined %1[%%c] IF !%1[%%c]! LEQ !%1[%%b]! (
  525.      Set "tmpV=!%1[%%c]!"
  526.      Set "tmpS=!btn[Dice][%%c]{state}!"
  527.      Set "%1[%%c]=!%1[%%b]!"
  528.      Set "%1[%%b]=!tmpV!"
  529.  REM swap state of dice retention if defined
  530.      If defined tmpS If defined btn[Dice][%%b]{state} (
  531.       Set "btn[Dice][%%c]{state}=!btn[Dice][%%b]{state}!"
  532.       Set "btn[Dice][%%b]{state}=!tmpS!"
  533.      )
  534.  ))))
  535. Exit /B 0
  536.  
  537.  
  538. :#Rolls ===================== Enact Individual Die Rolls For any Dice to be rolled / not retained
  539.  Set /A RollCount+=1
  540.  TITLE Turn:!TurnCount! -- Roll: !RollCount! -- HighScore:!HighScore!
  541.  Cls
  542.  <nul Set /p "=%\E%[14;1H"
  543.  For /L %%i in (1 1 5)Do For %%v in ("!Roll[%%i]!")Do if not "!Roll[%%i]!"=="" (
  544.   <nul Set /P "=!d%%~v!"
  545.  )
  546.  
  547.  Set "$Roll="
  548.  If not "%~1"=="" (%= Enact for /l loop only if arg 1 a positive integer =%
  549.   Set /A "Roll[i]=%~1","1/(%~1>>31)" 2> nul || Set /a "1/%~1" 2> nul && For /L %%R in (1 1 %~1)Do If "!Roll[%%R]!"=="" (
  550.    Set /A "Y=2,X=1","Old=!Random! %%6 +1","Mod=!Random! %%3 + 6","Flips=!Random! %%Mod + Mod"
  551.    For /l %%i in (!Flips! -1 1)Do (%= Naturally flip die a random number of times =%
  552.     Set /A "Delay=(DelayBase / (%%i+1/2))*4"
  553.     2> nul (
  554.      For %%v in ("!Old!")Do (
  555.      REM enforce natural flips of the dice during the roll - Each side cannot flip to itself or its opposing side.
  556.       Set /A "F#=!Random! %% 6 + 1","1/(Old-F#)",!Side[%%~v]! || (
  557.        %ConstrainFlip% (
  558.         %ConstrainFlip% (
  559.          %ConstrainFlip% (
  560.           %ConstrainFlip% (
  561.            %ConstrainFlip% (
  562.             %ConstrainFlip% (
  563.              %ConstrainFlip% (
  564.               %ConstrainFlip% (
  565.                %ConstrainFlip% (
  566.                 %ConstrainFlip% (
  567.                  %ConstrainFlip% (
  568.                   %= Reroll probability failure to constrain Flip to adjacent side is approx 0 - NOT non-zero. =%
  569.                   %= No failures in 600000 test flips. In case of Failure - 'slide' on current face. =%
  570.                   Set "F#=!Old!"
  571.     ))))))))))))))
  572.     Set /A "Old=!F#!"
  573.     For %%v in ("!F#!")Do Echo(%\E%[?25l%BG%%\E%[!y!;!x!H%\E%7!DB!╔═════╗%\c%║ !F%%~v:~0,3! ║%\c%║ !F%%~v:~3,3! ║%\c%║ !F%%~v:~6,3!%\c%╚═════╝%\c%%\E%[13;1H%\E%[48;2;10;10;10m%\E%[K%\E%[48;2;;;120m%\E%[K%\E%[1E%\E%[0m
  574.     If not Defined DisableDelay For /l %%z in (1 1 !Delay!)Do REM ANIMATION DELAY-FLIP
  575.     Set /A "X+=%%i+(!Random! %%7 - 2)","LY=Y"
  576.    Rem Restrict Y value to random range range 2-8. Modulo of X value by Flip number used to implement approximation of bouncing
  577.     Set /A "Y=(X %% %%i-2)","1/(-1-(Y>>31))","1/Y","1/(8/Y)","1/(Y-1)" 2> nul || Set /A "Y=LY+1","1/(8/Y)" 2> nul || Set /A "Y=LY"
  578.    )
  579.    Set "Roll[%%R]=!F#!"
  580.    Set "Roll[i]=%%R"
  581.    Set "$Roll=!$Roll! !F#!"
  582.    Call:SortRolls Roll 5
  583.    <nul Set /p "=%\E%[14;1H"
  584.    For /L %%i in (1 1 5)Do For %%v in ("!Roll[%%i]!")Do if not "!Roll[%%i]!"=="" (
  585.     <nul Set /P "=!d%%~v!"
  586.    )
  587.    If not Defined DisableDelay For /l %%z in (1 1 !EORdelay!)Do REM ANIMATION DELAY-END OF ROLL
  588.    <nul Set /P "=%\E%[1;1H%\E%7"
  589.    <nul Set /p "=%\E%[13;1H"
  590.   )
  591.  )
  592.  If Defined DisableDelay For /l %%z in (1 1 !EORdelay!)Do REM DELAY-END OF ROLL reduce risk of clicking continue unintentionally
  593. Exit /B 0
  594.  
  595.  
  596. :Buttons ================== Macro definitions and exe creation to facilitate Button Input.
  597.  
  598. REM ** IMPORTANT NOTE: WINDOWS 11 has different Virtual terminal Syntax which broke this script.
  599. REM scipt has been updated to resolve this issue, by replacing previous supported Syntax for moving cursor
  600. REM up \EA down \EB Left \ED right \EC with explicit values: up \E[1A down \E[1B Left \E[1D right \E[1C
  601.  
  602. :# As exampled at: https://youtu.be/ZYhvUbek4Xc
  603.  
  604. :# Batch clickable button macros and example functions
  605. :# Author: T3RRY Version: 2.0.5 Last Update: 11/01/2022
  606. :# New features:
  607. :# Added 'def' arg to allow this file to be called to define macros for use in a calling file.
  608. :#  - Note:
  609. :#        - Delayed Expansion be DISabled prior to defining macros
  610. :#        - Delayed Expansion must be ENabled to expand macros
  611. :# Expanded help information
  612. :# Reduced number of macros and functions to simplify usage
  613. :# Added new switches to make.btn for controlling button toggle type and defaults
  614. :# Added prompt for permission to install bg.exe ; a required component of this file.
  615.  
  616. :testEnviron
  617.  If "!!" == "" (Goto :button_help)
  618.  Set "Buttons_File=%~f0"
  619.  
  620. (Set \n=^^^
  621.  
  622. %= \n macro newline variable. Do not modify =%)
  623. (Set LF=^
  624.  
  625.  
  626. %= LF newline variable. Do not modify =%)
  627.  
  628. CLS
  629.  
  630. ====================:# OS Requirement tests
  631. :# Verify NTFS drive ** ADS Used to store Settings applied in demo function ColorMod
  632.  (Echo(verify.NTFS >"%~f0:Status") || (
  633.   Echo(This file must be located on an NTFS drive as it utilises Alternate Data Streams.
  634.   Pause
  635.   Exit /B 1
  636.  )
  637.  
  638.  For /f "Delims=" %%e in ('Echo(Prompt $E^|cmd')Do Set "\E=%%~e"
  639.  
  640.  Call:TestVT
  641.  
  642. :# Buttons macro Based on function at: https://www.dostips.com/forum/viewtopic.php?f=3&t=9222
  643.  
  644. :# Script Structure:
  645. :# OS and Exe Validation
  646. :# - Variable and macro Setup
  647. :#  - Functions
  648. :#   - Macro help handling
  649. :#    - [Script Break - Jump to :Main]
  650. :#     - Embedded Exe for Mouse and Key Inputs
  651. :#      - Main script body
  652.  
  653.  Set "reg.restore=(Call )"
  654.  
  655. :# disable QuickEdit if enabled. Restored at :end label if disabled by script
  656.   For /f "skip=1 Tokens=3" %%G in ('reg query HKEY_CURRENT_USER\console\ /v Quickedit')Do Set "QE.reg=%%G"
  657.    If "%QE.reg%" == "0x1" (
  658.    (Reg add HKEY_CURRENT_USER\console\ /v QuickEdit /t REG_DWORD /d 0x0 /f) > nul
  659.    Set "reg.restore=Reg add HKEY_CURRENT_USER\console\ /v QuickEdit /t REG_DWORD /d 0x1 /f"
  660.   )
  661.  
  662.  If not exist "%TEMP%\BG.exe" (
  663.   Echo(%\E%[33mThis program requires Bg.exe to run.%\E%[0m
  664.   Echo( Install from this file %\E%[32m[Y]%\E%[0m or Exit %\E%[31m[N]%\E%[0m ?
  665.   For /f "delims=" %%C in ('%SystemRoot%\System32\choice.exe /N /C:YN')Do if %%C==Y (
  666.    Certutil -decode "%~f0" "%TEMP%\BG.exe" > nul
  667.   )Else Exit /B 1
  668.   Cls
  669.  )
  670.  
  671.  Set BG.exe="%TEMP%\BG.exe"
  672.  
  673.  For /f "tokens=4 Delims=: " %%C in ('CHCP')Do Set "active.cp=%%C"
  674.  chcp 65001 > nul
  675.  
  676.  Set "/??=0"
  677. :#0  \E33m
  678. :#0 Call this file with one of the below macro or function \E37mNames\E33m
  679. :#0 to see it's full usage information.
  680. :#0  \E36m
  681. :#0 Macros: \E37m
  682. :#0  Make.Btn   \E38;2;61;61;61m %Make.Btn% GroupName /S button text \E37m
  683. :#0  Get.Click  \E38;2;61;61;61m %Get.Click% GroupName OtherGroupName \E37m
  684. :#0  If.Btn     \E38;2;61;61;61m %If.Btn[Groupname]%[#] command \E37m
  685. :#0  Buffer     \E38;2;61;61;61m %Buffer:@=Alt% \E37m
  686. :#0             \E38;2;61;61;61m %Buffer:@=Main% \E37m
  687. :#0  Clean.Exit \E38;2;61;61;61m %Clean.Exit%
  688. :#0  \E36m
  689. :#0 Functions: \E37m
  690. :#0  YesNo      \E38;2;61;61;61m Call :YesNo "Option 1" "Option 2" "Spoken Prompt"
  691. :#0  \E36m
  692. :#0 Define macros for use in a calling .bat or .cmd script: \E37m
  693. :#0  Call buttons.bat def
  694. :#0
  695.  
  696.  Set "Buffer?=1"
  697. :#1 \E36m
  698. :#1 Usage:   %Buffer:@=Alt%
  699. :#1 \E0m          - Switch to Alt buffer; preserving content of main screen buffer.
  700. :#1 \E36m
  701. :#1          %Buffer:@=Main%
  702. :#1 \E0m          - Returns to main screen buffer.
  703. :#1
  704.  Set "Buffer.Hash=@"
  705.  Set "Buffer=If not "!Buffer.Hash!"=="@" ( <nul set /p "=!@!" )Else (Cls&Call "%~f0" Buffer&Call Echo(%\E%[31mUsage Error in %%0 - Missing or Incorrect Substitution^^!%\E%[0m&Pause &Exit)"
  706.  Set "Alt=%\E%[?1049h%\E%[?25l"
  707.  Set "Main=%\E%[?25h%\E%[?1049l%\E%[?25l"
  708.  
  709. :# button sound fx. disable by undefining buttonsfx below ; prior to definition of OnCLick macro
  710.  Set "buttonsfx=On"
  711.  %BG.exe% Play "%WINDIR%\Media\Windows Feed Discovered.wav"
  712.  Set "OnClick=(Call )"
  713.  Set "OnType=(Call )"
  714.  If defined buttonsfx (
  715.   For /f "Delims=" %%G in ('Dir /b /s "%WINDIR%\SystemApps\*KbdKeyTap.wav"')Do If exist "%%~G" Set "OnClick=(Start /b "" %BG.exe% Play "%%~G")"
  716.   Set "OnType=(start /b "" %BG.exe% Play "%WINDIR%\Media\Windows Feed Discovered.wav")"
  717.  )
  718.  
  719.  Set "Get.Click?=2"
  720. :#2 \E36m
  721. :#2 Usage: %Get.Click% \E0m{^<\E31mGroupName\E0m^> ^| ^<\E31mGroupName\E0m^> ^<\E31mOtherGroupName\E0m^>}
  722. :#2 \E33m
  723. :#2 Performs the following Actions: \E0m
  724. :#2  - Launches Bg.exe with mouse arg to get mouse click
  725. :#2  - Assigns 1 indexed Y;X pos of mouse click to c{Pos}
  726. :#2  - Performs a conditional comparison via substring modifications
  727. :#2    of all buttons Coordinates defined in each btn[GroupName] array
  728. :#2    matching against the Y;X value of c{Pos}
  729. :#2 \E33m
  730. :#2 On clicked position matching a buttons defined Coordinates: \E0m
  731. :#2  - If %Make.Btn% /T or /TM Switches used to define defined btn[Groupname][Index]{t}:
  732. :#2    - /T:
  733. :#2      - Toggles button visually by inverting colors
  734. :#2      - Toggles btn[Groupname][Index]{state} variable value: true / false
  735. :#2    - /TM:
  736. :#2      - Forces btn[Groupname][Index]{state} true for clicked button.
  737. :#2      * Use In conjunction with /D 'default' or /CD 'Conditional Default' switch
  738. :#2        when a mandatory single selection is required.
  739. :#2  - Defines the following:
  740. :#2     If.btn[GroupName]=\E35mIf [Groupname][Index] == [GroupName]\E0m
  741. :#2     Group=GroupName
  742. :#2     Clicked[Groupname]=Button Text
  743. :#2     ValidClick[GroupName]=[GroupName][Index]
  744. :#2     - Tip reference values directly using: \E36m
  745. :#2       !Clicked[%Group%]!
  746. :#2       !ValidClick[%Group%]!  \E0m
  747. :#2  - Plays the system file KbdKeyTap.wav [If Present] as a clicking sound.
  748. :#2 \E33m
  749. :#2 On clicked position not matching a buttons defined Coordinates: \E0m
  750. :#2  - Defines:
  751. :#2     If.btn[GroupName]=\E36mIf Not.Clicked ==\E0m
  752. :#2  - Undefined:
  753. :#2     Group
  754. :#2      - To loop to a label and wait for a valid click of any
  755. :#2        button defined to a supplied GroupName, Use:
  756. :#2        \E36mIf not defined Group Goto :\E33mlabel\E0m
  757. :#2     Clicked[Groupname]
  758. :#2     ValidClick[GroupName]
  759. :#2
  760.  Set "If.Btn?=4"
  761. :#4 \E36m
  762. :#4 Usage: %If.btn\E35m[GroupName]\E36m%\E31m[Index] \E90m(Command)\E0m
  763. :#4
  764. :#4  -\E33m Compares clicked button \E0m[GroupName][Index]\E33m against \E0m[Groupname]\E31m[arg]\E0m
  765. :#4
  766.  
  767. :# return button click coords in c{pos} variable n Y;X format
  768.  Set Get.Click=For %%n in (1 2)Do if %%n==2 (%\n%
  769.   Set "Group="%\n%
  770.   For %%G in (!GroupName!)Do (%\n: Update display of toggle state =%
  771.    For /l %%i in (1 1 !Btns[%%G][i]!)Do (%\n%
  772.     If not "!Btn[%%G][%%i]{state}!"=="true" (%\n%
  773.      ^<nul set /P "=!Btn[%%G][%%i]!"%\n%
  774.     )Else If Defined Btn[%%G][%%i]{t} (%\n%
  775.      set "tmpstr=!Btn[%%G][%%i]:38=7;38!"%\n%
  776.      ^<nul set /P "=!tmpstr:48=7;48!"%\n%
  777.   )))%\n%
  778.   for /f "tokens=1,2" %%X in ('%BG.exe% mouse')Do (%\n: Wait for mouse input =%
  779.    Set /A "c{pos}=%%X+1"                         %\n: Adjust X axis for 1 index =%
  780.    Set "c{pos}=!c{Pos}!;%%Y"                     %!!%
  781.    For %%G in (!GroupName!)Do (                  %\n: iterate over list of supplied group names =%
  782.     Set "If.Btn[%%G]=If Not.Clicked =="          %\n: assign or clear default values for return variables =%
  783.     Set "Clicked[%%G]="%\n%
  784.     Set "ValidClick[%%G]="%\n%
  785.     Set "ValidClick[%%G]{t}="%\n%
  786.     For /F "Delims=" %%C in ("!c{Pos}!")Do (     %\n: expand Coordinate var for use in substring modification =%
  787.      For /l %%I in (1 1 !btns[%%G][I]!)Do (      %\n: test if [Y;X] Coord contained in btn Coord Var =%
  788.       If not "!btn[%%G][%%I][Coord]:[%%C]=!" == "!btn[%%G][%%I][Coord]!" (%\n%
  789.        %OnClick%                                 %\n: play click sound effect if available =%
  790.        Set "Group=%%G"                           %\n: assign groupname value the button clicked belongs to =%
  791.        Set "If.Btn[%%G]=If [%%G][%%I] == [%%G]"  %\n: define If.Btn[GroupName] macro =%
  792.        Set "ValidClick[%%G]=[%%G][%%I]"          %\n: assign [GroupName][Index] of clicked button =%
  793.        Set "Clicked[%%G]=!Btn[%%G][%%I][String]!"%\n: assign the text containd in the clicked button =%
  794.        If Defined Btn[%%G][%%I][items] (%\n%
  795.         Set Btn[%%G][%%I][items]="!Btn[%%G][%%I][items]:{EQ}==!"%\n%
  796.         Set "Btn[%%G][%%I][items]=!Btn[%%G][%%I][items]: =" "!"%\n%
  797.         Set "Tmp.Items=!Btn[%%G][%%I][items]!"%\n%
  798.         Set "Btn[%%G][%%I][items]="%\n%
  799.         For %%t in (!Tmp.Items!)Do (%\n%
  800.          Set "tmp.str=%%~t"%\n%
  801.          Set "tmp.str=!tmp.Str:_= !"%\n%
  802.          Set "!tmp.str!"%\n%
  803.          Echo(!tmp.str!^|findstr.exe /R "[0-9]" ^> nul ^|^| Set "Btn[%%G][%%I][items]=!Btn[%%G][%%I][items]! "!tmp.str!""%\n%
  804.         )%\n%
  805.        )%\n%
  806.        If Defined Btn[%%G][%%I]{t} (             %\n: toggle state handling. =%
  807.         Set "ValidClick[%%G]{t}=[%%G][%%I]"      %\n: flag toggle state change for toggle.If.Not macro =%
  808.         If "!Btn[%%G][%%I]{state}!"=="true" (    %\n: update console display of toggle state by inverting colors =%
  809.         If not defined Btn[%%G][%%I]{m} (%\n%
  810.          ^<nul set /P "=!Btn[%%G][%%I]!"%\n%
  811.           Set "Btn[%%G][%%I]{state}=false"%\n%
  812.          )%\n%
  813.         )Else (%\n%
  814.          set "tmpstr=!Btn[%%G][%%I]:38=7;38!"%\n%
  815.          ^<nul set /P "=!tmpstr:48=7;48!"%\n%
  816.          Set "Btn[%%G][%%I]{state}=true"%\n%
  817.   )))))))%\n%
  818.  )Else Set GroupName=
  819.  
  820.  Set "Toggle.If.not?=5"
  821. :#5 \E36m
  822. :#5 Usage: %Toggle.If.Not% \E0m{^<\E31m[Groupname][Index]\E0m^> ^| ^<\E31m[Groupname][Index]\E0m^> ^<\E31m[OtherGroupname][Index]\E0m^>}
  823. :#5 \E33m
  824. :#5 Macro Actions: \E0m
  825. :#5 - Defines {state} false for all toggle buttons in GroupName except [Groupname][Index]
  826. :#5 - Updates Display Color of all buttons; Inverting each button with {state}=true
  827. :#5
  828. :#5 * Multiple [GroupName][Index]'s \E31m with unique GroupNames \E0m may be supplied
  829. :#5 \E33m
  830. :#5 Example usage:\E36m
  831. :#5 %Toggle.If.Not% !ValidClick[GroupName]!
  832. :#5 \E0m
  833.  Set Toggle.If.not=For %%n in (1 2)Do if %%n==2 (%\n%
  834.   For /f "tokens=1,2 Delims=[]" %%G in ("!GroupName: =!")Do (%\n: Remove spaces from arg assignment =%
  835.    If defined ValidClick[%%G]{t} (               %\n: If state change flagged true in Get.Click macro =%
  836.     For /l %%i in (1 1 !btns[%%G][i]!)Do (       %\n: test each button in groupname =%
  837.      If not "%%i"=="%%H" (                       %\n: If not button EQU clciked button =%
  838.       Set "btn[%%G][%%i]{state}=false"           %\n: Force btn[%%G][%%i]{state} false =%
  839.       ^<nul Set /P "=!btn[%%G][%%i]!"            %\n: Display button in standard unselected color =%
  840.   ))))%\n%
  841.  )Else Set GroupName=
  842.  
  843.  Set "Clean.Exit?=7"
  844. :#7
  845. :#7 Clean.Exit \E33m
  846. :#7  Restores codepage and Quickedit registry state
  847. :#7  Clears the title and screen ; ends the local environment
  848. :#7  executes Goto :Eof
  849. :#7 \E0m
  850.  Set Clean.Exit=(%\n%
  851.   cls %\n%
  852.   (%Reg.Restore%) ^> nul %\n%
  853.   (Title ) %\n%
  854.   ^<nul set /p "=%\E%[?25h" %\n%
  855.   CHCP %active.cp% ^> nul %\n%
  856.   Endlocal %\n%
  857.   Goto :Eof %\n%
  858.  )
  859.  
  860.  Set "Make.Btn?=9"
  861. :#9  \E33m
  862. :#9 Make.Btn Macro Usage: \E36m
  863. :#9 %Make.Btn%\E0m ^<\E31mGroupName\E0m^> ^<\E31m/S "Btn text"\E0m^> [\E32m/Y Coord\E0m] [\E32m/X Coord\E0m] [\E32m/FG R G B\E0m]
  864. :#9            [\E32m/BG R G B\E0m] [\E32m/BO \E0m{\E33mR G B\E0m^|\E33mR G B + R G B\E0m^|\E33mValue\E0m}] [\E32m/T\E0m] [\E32m/N\E0m]
  865. :#9            [^<\E31m/TM\E0m^> [\E32m/D\E0m]^|[\E32m/CD Variable\E0m]]
  866. :#9  \E37m
  867. :#9  - Arg 1 must be Groupname. Switch order is NOT mandatory.
  868. :#9  \E36m
  869. :#9   /N \E37mReset button count for GroupName (Arg 1) to 0. use when creating buttons in a :label that is returned to. \E36m
  870. :#9   /T \E37mDefine button as toggleable. Button state: 'Btn[Groupname][i]{state}' variable
  871. :#9      alternates true or false when clicked; and clicked buttons Color is inverted on match. \E36m
  872. :#9   /TM \E0m'Toggle Mandatory' as above; however mandatory true state for last selected button \E36m
  873. :#9      /D  \E0m'default selection' ; Flags toggle {state} true on definition. \E31m * Requires \E36m/TM
  874. :#9      /CD \E0m'Conditional default selection' ; If /CD Variable contains /S string
  875. :#9           Flags toggle {state} true on definition. \E31m * Requires \E36m/TM
  876. :#9
  877. :#9 Note: \E36m/BO \E37m{'Button box'} may supply a pair of R G B values for FG and BG by concatenating values with '+'
  878. :#9   IE: '\E36m/BO \E38;2;255;0;0m\E48;2;0;0;100m38 2 255 0 0 + 48 2 0 0 100\E0m'
  879. :#9   R G B sequences are groups of three integers between 0 and 255. Each R G B value adjusts the intensity of
  880. :#9  that color. Valid values for Virtual terminal sequences can be referenced at:
  881. :#9  \E32m https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences#text-formatting
  882. :#9  \E33m
  883. :#9 Default Y and X Coordinates is used are /X value is ommited \E37m
  884. :#9 - Button defaults to next X spacing if /Y position included ; Else X = 2
  885. :#9 - Button defaults to next Y spacing if /Y ommited ;
  886. :#9   - defaults to previous /X spacing if /X also ommited
  887. :#9
  888. :#9 \E38;2;81;81;81mExpansion time is approxiamtely 1/33rd of a second when all switches used.
  889. :#9 \E0m
  890.  
  891.  Set Make.Btn[Switches]="S" "Y" "X" "FG" "BG" "BO" "T" "TM" "D" "N" "CD" "Def"
  892.  
  893.  Set Make.Btn=For %%n in (1 2)Do if %%n==2 (                              %\n: CAPTURE ARG STRING =%
  894.   Set "Make.Btn[Syntax]=%\E%[33m!Make.Btn[args]!"%\n%
  895.   For /F "Tokens=1,2 Delims==" %%G in ('Set "Make.Btn_" 2^^^> nul')Do Set "%%~G=" %\n: RESETS ALL MACRO INTERNAL VARS =%
  896.   If not "!Make.Btn[args]:* /=!" == "!Make.Btn[args]!" (                              %\n: BUILD Make.Btn.Args[!Make.Btn_arg[i]!] ARRAY IF ARGS PRESENT =%
  897.    Set "Make.Btn_leading.args=!Make.Btn[args]:*/=!"                                   %\n: SPLIT ARGS FROM SWITCHES =%
  898.    For /F "Delims=" %%G in ("!Make.Btn_leading.args!")Do Set "Make.Btn_leading.args=!Make.Btn[args]:/%%G=!"%\n%
  899.    Set ^"Make.Btn[args]=!Make.Btn[args]:"=!"                                          %\n: REMOVE DOUBLEQUOTES FROM REMAINING ARGSTRING - SWITCHES =%
  900.    Set "Make.Btn_arg[i]=0"                                                            %\n: ZERO INDEX FOR ARGS ARRAY =%
  901.    For %%G in (!Make.Btn_leading.args!)Do (                                           %\n: BUILD ARGS ARRAY =%
  902.     Set /A "Make.Btn_arg[i]+=1"%\n%
  903.     Set "Make.Btn_arg[!Make.Btn_arg[i]!]=%%~G"%\n%
  904.     For %%i in ("!Make.Btn_arg[i]!")Do (                                              %\n: SUBSTITUTE THE FOLLOWING POISON CHARACTERS =%
  905.      Set "Make.Btn_arg[%%~i]=!Make.Btn_arg[%%~i]:{SC}=;!"%\n%
  906.      Set "Make.Btn_arg[%%~i]=!Make.Btn_arg[%%~i]:{QM}=?!"%\n%
  907.      Set "Make.Btn_arg[%%~i]=!Make.Btn_arg[%%~i]:{FS}=/!"%\n%
  908.      Set "Make.Btn_arg[%%~i]=!Make.Btn_arg[%%~i]:{AS}=*!"%\n%
  909.      Set "Make.Btn_arg[%%~i]=!Make.Btn_arg[%%~i]:{EQ}==!"%\n%
  910.      Set ^"Make.Btn_arg[%%~i]=!Make.Btn_arg[%%~i]:{DQ}="!"%\n%
  911.   ))) Else (                                                                           %\n: IF NO ARGS REMOVE DOUBLEQUOTES FROM ARGSTRING - SWITCHES =%
  912.    Set ^"Make.Btn[args]=!Make.Btn[args]:"=!"%\n%
  913.    Set "Make.Btn_Arg[1]=!Make.Btn[args]!"%\n%
  914.    Set "Make.Btn_Arg[i]=1"%\n%
  915.   )%\n%
  916.   For /L %%L in (2 1 4)Do If "!Make.Btn_LastSwitch!" == "" (%\n%
  917.    If "!Make.Btn[args]:~-%%L,1!" == " " Set "Make.Btn_LastSwitch=_"%\n%
  918.    If "!Make.Btn[args]:~-%%L,1!" == "/" (                                              %\n: FLAG LAST SWITCH TRUE IF NO SUBARGS ; FOR SWITCHES UP TO 3 CHARCTERS LONG =%
  919.     For /F "Delims=" %%v in ('Set /A "%%L-1"')Do Set "Make.Btn_Switch[!Make.Btn[args]:~-%%v!]=true"%\n%
  920.     If not "!Make.Btn[args]:/?=!." == "!Make.Btn[args]!." Set "Make.Btn_Switch[help]=true"%\n%
  921.     Set "Make.Btn[args]=!Make.Btn[args]:~0,-%%L!"%\n%
  922.     Set "Make.Btn_LastSwitch=_"%\n%
  923.    )%\n%
  924.   )%\n%
  925.   For %%G in ( %Make.Btn[Switches]% )Do If not "!Make.Btn[args]:/%%~G =!" == "!Make.Btn[args]!" (%\n: SPLIT AND ASSIGN SWITCH VALUES =%
  926.    Set "Make.Btn_Switch[%%~G]=!Make.Btn[args]:*/%%~G =!"%\n%
  927.    If not "!Make.Btn_Switch[%%~G]:*/=!" == "!Make.Btn_Switch[%%~G]!" (%\n%
  928.     Set "Make.Btn_Trail[%%~G]=!Make.Btn_Switch[%%~G]:*/=!"%\n%
  929.     For %%v in ("!Make.Btn_Trail[%%~G]!")Do (%\n%
  930.      Set "Make.Btn_Switch[%%~G]=!Make.Btn_Switch[%%~G]: /%%~v=!"%\n%
  931.      Set "Make.Btn_Switch[%%~G]=!Make.Btn_Switch[%%~G]:/%%~v=!"%\n%
  932.     )%\n%
  933.     Set "Make.Btn_Trail[%%~G]="%\n%
  934.     If "!Make.Btn_Switch[%%~G]:~-1!" == " " Set "Make.Btn_Switch[%%~G]=!Make.Btn_Switch[%%~G]:~0,-1!"%\n%
  935.     If "!Make.Btn_Switch[%%~G]!" == "" Set "Make.Btn_Switch[%%~G]=true"%\n%
  936.     If not "!Make.Btn_Switch[%%~G]!" == "" If not "!Make.Btn_Switch[%%~G]!" == "true" (%\n%
  937.      Set "Make.Btn_Switch[%%~G]=!Make.Btn_Switch[%%~G]:{SC}=;!"%\n%
  938.      Set "Make.Btn_Switch[%%~G]=!Make.Btn_Switch[%%~G]:{QM}=?!"%\n%
  939.      Set "Make.Btn_Switch[%%~G]=!Make.Btn_Switch[%%~G]:{FS}=/!"%\n%
  940.      Set "Make.Btn_Switch[%%~G]=!Make.Btn_Switch[%%~G]:{AS}=*!"%\n%
  941.      Set "Make.Btn_Switch[%%~G]=!Make.Btn_Switch[%%~G]:{EQ}==!"%\n%
  942.      Set ^"Make.Btn_Switch[%%~G]=!Make.Btn_Switch[%%~G]:{DQ}="!"%\n%
  943.    ))%\n%
  944.    If "!Make.Btn_Switch[%%~G]:~-1!" == " " Set "Make.Btn_Switch[%%~G]=!Make.Btn_Switch[%%~G]:~0,-1!"%\n%
  945.   )%\n: ACTION SWITCH ASSESSMENT BELOW. USE CONDITIONAL TESTING OF VALID SWITCHES OR ARGS ARRAY TO ENACT COMMANDS FOR YOUR MACRO FUNCTION =%
  946.   If not defined Make.Btn_Arg[1] (%\n:           Enforce button Groupname Definiton via Arg 1 =%
  947.    Call "%Buttons_File%" Make.Btn%\n%
  948.    ^<nul Set /P "=%\E%[E ^! %\E%[31mMissing Arg 1 GroupName in:%\E%[36m %%Make.btn%%%\E%[31m GroupName!Make.Btn[Syntax]:  = !%\E%[0m%\E%[E"%\n%
  949.    Pause %\n%
  950.    cls %\n%
  951.    (%Reg.Restore%) ^> nul %\n%
  952.    (Title ) %\n%
  953.    ^<nul set /p "=%\E%[?25h" %\n%
  954.    CHCP %active.cp% ^> nul %\n%
  955.    Endlocal %\n%
  956.    Goto :Eof %\n%
  957.   )%\n%
  958.   If not defined Make.Btn_Switch[S] (%\n:        Enforce button text definition via /S switch parameter value =%
  959.    Call "%Buttons_File%" Make.Btn%\n%
  960.    ^<nul Set /P "=%\E%[E ^! %\E%[31mMissing Switch /S in:%\E%[36m %%Make.btn%%!Make.Btn[Syntax]:  = ! %\E%[31m/S Button text%\E%[0m%\E%[E"%\n%
  961.    Pause %\n%
  962.    cls %\n%
  963.    (%Reg.Restore%) ^> nul %\n%
  964.    (Title ) %\n%
  965.    ^<nul set /p "=%\E%[?25h" %\n%
  966.    CHCP %active.cp% ^> nul %\n%
  967.    Endlocal %\n%
  968.    Goto :Eof %\n%
  969.   )%\n%
  970.   For %%e in ("!Make.Btn_Arg[1]!")Do (%!!%
  971.    If defined Make.Btn_Switch[N] (%\n:           Reset button group index and X Y positions if /N switch used =%
  972.     Set "Btn[%%~e][X]="%\n%
  973.     Set "Btn[%%~e][Y]="%\n%
  974.     Set "Btns[%%~e][i]=0"%\n%
  975.    )%\n%
  976.    If defined Make.Btn_Switch[Y] (%\n:           Determine button Y Position according to /Y switch usage or default increment =%
  977.     Set /A "Btn[%%~e][Y]=!Make.Btn_Switch[Y]!"%\n%
  978.    )Else (%\n%
  979.     Set /A "Btn[%%~e][Y]+=3+0"%\n%
  980.    )%\n%
  981.    If defined Make.Btn_Switch[X] (%\n:           Determine button X Position according to /X usage or default increment =%
  982.     Set /A "Btn[%%~e][X]=!Make.Btn_Switch[X]!"%\n%
  983.    )Else (%\n%
  984.     If defined Make.Btn_Switch[Y] (%\n%
  985.      Set /A "Btn[%%~e][X]=!L[%%~e][X]!+0"%\n%
  986.     )Else (%\n%
  987.      If not defined Btn[%%~e][X] Set "Btn[%%~e][X]=2"%\n%
  988.    ))%\n%
  989.    If !Btn[%%~e][X]! LSS 1 ( Set "Btn[%%~e][X]=1" )%\n: Constrain X min to One =%
  990.    Set /a "Btns[%%~e][i]+=1+0"%\n:               Increment button Index =%
  991.    For %%f in ("!Btns[%%~e][i]!")Do (%\n:        Expand button index =%
  992.     Set "Btn[%%~e][!Btns[%%~e][i]!][p]=!Btn[%%~e][Y]!;!Btn[%%~e][X]!"%\n%
  993.     Set "Btn[%%~e][!Btns[%%~e][i]!][string]=!Make.Btn_Switch[S]!"%\n%
  994.     If /I "!Make.Btn_Switch[T]!"=="true" (%\n:   Define toggle vars according to /T or /TM switche usage =%
  995.      Set "Btn[%%~e][%%~f]{t}=true"%\n%
  996.      Set "Btn[%%~e][%%~f]{state}=false"%\n%
  997.     ) Else If /I "!Make.Btn_Switch[TM]!"=="true" (%\n%
  998.      Set "Btn[%%~e][%%~f]{t}=true"%\n%
  999.      Set "Btn[%%~e][%%~f]{state}=false"%\n%
  1000.      Set "Btn[%%~e][%%~f]{m}=true"%\n%
  1001.     ) Else (%\n:                                 If /Tor /TM toggle switches not used ; ensure toggle vars undefined =%
  1002.      Set "Btn[%%~e][%%~f]{t}="%\n%
  1003.      Set "Btn[%%~e][%%~f]{state}="%\n%
  1004.      Set "Btn[%%~e][%%~f]{m}="%\n%
  1005.     )%\n%
  1006.     If defined Make.Btn_Switch[D] (%\n:          Define button as toggle state true =%
  1007.      If defined Btn[%%~e][%%~f]{t} (%\n:         if button is defined as toggleable =%
  1008.       Set "Btn[%%~e][%%~f]{state}=true"%\n%
  1009.     ))%\n%
  1010.     If defined Make.Btn_Switch[CD] (%\n:         Test supplied variable for contents of button text =%
  1011.      If defined Btn[%%~e][%%~f]{t} (%\n:         if button is defined as toggleable =%
  1012.       For %%1 in ("!Make.Btn_Switch[CD]!")Do (%\n%
  1013.        For %%2 in ("!Make.Btn_Switch[S]!")Do (%\n%
  1014.         If not "!%%~1:%%~2=!"=="!%%~1!" (%\n:     Define button as toggle state true on match =%
  1015.          Set "Btn[%%~e][%%~f]{state}=true"%\n%
  1016.     )))))%\n%
  1017.     If defined Make.Btn_Switch[FG] (%\n:         Assign Foreground color =%
  1018.      Set "Btn[%%~e][FG]=%\E%[38;2;!Make.Btn_Switch[FG]: =;!m"%\n%
  1019.     )Else (%\n%
  1020.      set "Btn[%%~e][FG]=%\E%[38;2;0;0;0m"%\n%
  1021.     )%\n%
  1022.     Set "Btn[%%~e][%%~f][FG]=!Btn[%%~e][FG]!"%\n%
  1023.     Set "Btn[%%~e][%%~f][iFG]=!Btn[%%~e][FG]:[38=48!"%\n%
  1024.     If defined Make.Btn_Switch[BG] (%\n%
  1025.      Set "Btn[%%~e][BG]=%\E%[48;2;!Make.Btn_Switch[BG]: =;!m"%\n%
  1026.     )Else (%\n%
  1027.      Set "Btn[%%~e][BG]=%\E%[48;2;230;230;200m"%\n%
  1028.     )%\n%
  1029.     Set "Btn[%%~e][%%~f][BG]=!Btn[%%~e][BG]!"%\n%
  1030.     Set "Btn[%%~e][%%~f][iBG]=!Btn[%%~e][BG]:[48=38!"%\n%
  1031.     If defined Make.Btn_Switch[BO] (%\n:         Process value of /BO border color =%
  1032.      Set "Btn[%%~e][Col]=!Btn[%%~e][Col]: + =m%\E%[!"%\n%
  1033.      Set "Btn[%%~e][Col]=%\E%[!Make.Btn_Switch[BO]: =;!m"%\n%
  1034.      Set "Btn[%%~e][Col]=!Btn[%%~e][Col]:+=m%\E%[!"%\n%
  1035.      Set "Btn[%%~e][Col]=!Btn[%%~e][Col]:[;=[!"%\n%
  1036.      Set "Btn[%%~e][Col]=!Btn[%%~e][Col]:;;=;!"%\n%
  1037.      Set "Btn[%%~e][Col]=!Btn[%%~e][Col]:;m=m!"%\n%
  1038.     ) Else (%\n:                                 Enact default border color if no value supplied =%
  1039.      set "Btn[%%~e][Col]=%\E%[90m"%\n%
  1040.     )%\n%
  1041.     Set "Btn[%%~e][%%~f][BO]=!Btn[%%~e][Col]!"%\n%
  1042.     Set "len="%\n:                               Get string length of button text =%
  1043.     Set "tmp.s=#!Make.Btn_Switch[S]!"%\n%
  1044.     For %%P in (8192 4096 2048 1024 512 256 128 64 32 16 8 4 2 1) do (%\n%
  1045.      If "!tmp.s:~%%P,1!" NEQ "" (%\n%
  1046.       Set /a "len+=%%P"%\n%
  1047.       Set "tmp.s=!tmp.s:~%%P!"%\n%
  1048.     ))%\n%
  1049.     Set /A "Btn{Xmin}=!Btn[%%~e][X]!+1", "Btn{Xmax}=!Btn[%%~e][X]!+len", "l[%%~e][X]=!Btn[%%~e][X]!+len+2"%\n%
  1050.     Set "Btn[%%~e][%%~f][S]="%\n%
  1051.     Set "Btn[%%~e][%%~f][Bar]="%\n%
  1052.     Set "Btn[%%~e][%%~f][Coord]="%\n%
  1053.     For /l %%i in (!Btn{Xmin}! 1 !Btn{Xmax}!)Do (%\n%
  1054.      Set /A "Btn[%%~e][%%~f][Len]=%%i-3", "Xoffset=%%i-1"%\n%
  1055.      Set "Btn[%%~e][%%~f][Coord]=!Btn[%%~e][%%~f][Coord]![!Btn[%%~e][Y]!;!Xoffset!]"%\n%
  1056.      Set "Btn[%%~e][%%~f][Bar]=!Btn[%%~e][%%~f][Bar]!═"%\n%
  1057.      Set "Btn[%%~e][%%~f][S]=!Btn[%%~e][%%~f][S]! "%\n%
  1058.     )%\n%
  1059.     Set /A "Btn[%%e][Cpos]=!Btn[%%~e][Y]!+2"%\n%
  1060.     If defined Make.Btn_Switch[Def] Set "btn[%%~e][%%~f][items]=!Make.Btn_Switch[Def]!"%\n%
  1061.     Set "Btn[%%~e][%%~f]=%\E%[!Btn[%%~e][Y]!;!Btn[%%~e][X]!H!Btn[%%~e][%%~f][BO]!%\E%7║%\E%8%\E%[1A╔!Btn[%%~e][%%~f][Bar]!╗%\E%8%\E%[1B╚!Btn[%%~e][%%~f][Bar]!╝%\E%8%\E%[1C%\E%[0m!Btn[%%~e][%%~f][FG]!!Btn[%%~e][%%~f][BG]!!Make.Btn_Switch[S]!%\E%[0m!Btn[%%~e][%%~f][BO]!%\E%[0m%\E%[2E%\E%7"%\n%
  1062.     Set "Btn[%%~e][%%~f][t]=%\E%[0m!Btn[%%~e][%%~f][FG]!!Btn[%%~e][%%~f][BG]!!Make.Btn_Switch[S]!%\E%[0m!Btn[%%~e][%%~f][BO]!%\E%[0m%\E%[K"%\n%
  1063.   ))%\n%
  1064.  %= ESCAPE AMPERSANDS AND REDIRECTION CHARACTERS.  =%) Else Set Make.Btn[args]=
  1065.  
  1066.  <nul set /p "=%\E%[?25l"
  1067.  
  1068.  If not "%~1" == "" (
  1069.   If /I not "%~1" == "def" (
  1070.    Goto :button_help
  1071.   )Else Exit /b 0
  1072.  )
  1073.  
  1074. ==========
  1075.  Goto :BUttonsMain
  1076. ==========
  1077.  
  1078. :# HELP INFO
  1079.  
  1080. ============
  1081. :button_help </?|Function_Name|Macro_Name>
  1082.  Set "_D="
  1083.  If not "%~1"=="" (
  1084.   Setlocal EnableDelayedExpansion
  1085.   Set "_D=!%~1?!"
  1086.  )
  1087.  Endlocal & Set "_D=%_D%"
  1088.  
  1089.  If not "%~1"=="" (
  1090.   If Defined _D (
  1091.    Mode 120,45
  1092.    (
  1093.     Echo(%\E%[36mSyntax: %\E%[0m^<%\E%[31mMandatory%\E%[0m^> [%\E%[32mOptional%\E%[0m] {%\E%[33mMutually^%\E%[0m^|%\E%[33mExclusive%\E%[0m}
  1094.     For /f "Tokens=2* Delims=%_D%" %%T in ('Findstr /BLIC:":#%_D%" "%Buttons_File%"')Do (
  1095.      Set "line=%%T"
  1096.      Call Set "line=%%line:buttons.bat="%~f0"%%"
  1097.      Call Echo(%%Line:\E=%\E%[%%
  1098.     )
  1099.    )> "%TEMP%\%~n0_Help"
  1100.    Type "%TEMP%\%~n0_Help" > Con
  1101.    Exit /B -1
  1102.   )Else (
  1103.    Findstr /BLIC:":%~1 " "%~f0" >nul && (
  1104.     Echo(%\E%[36mSyntax: %\E%[0m^<%\E%[31mMandatory%\E%[0m^> [%\E%[32mOptional%\E%[0m] {%\E%[33mMutually^%\E%[0m^|%\E%[33mExclusive%\E%[0m}
  1105.     <nul Set /P "=%\E%[K %~1 Usage:%\E%[2E Call "
  1106.     Findstr /BLIC:":%~1 " "%Buttons_File%"
  1107.     Exit /B -1
  1108.    ) || (
  1109.     Echo(Help query '%~1' does not match any existing Macro or Function.
  1110.     Echo(Check your Spelling and try again.
  1111.     Exit /B -1
  1112.    )
  1113.   )
  1114.  )Else (
  1115.   Echo(%\E%[33mDelayed Expansion %\E%[31mmust not %\E%[33mbe enabled prior to running %\E%[36m%~nx0%\E%[0m
  1116.   Exit /B -1
  1117.  )
  1118. Goto :eof
  1119.  
  1120. :TestHost ====================== Identify parent environment
  1121. REM function a derivitive of the method proposed by Mathieu at:
  1122. REM  https://discord.com/channels/288498150145261568/931201474338357300
  1123.  
  1124.  Setlocal EnableDelayedExpansion
  1125.  
  1126.  Set "ParentProcessID="
  1127.  wmic process get parentprocessid,name |find "WMIC" 1>"%TEMP%\PID.dat"
  1128.  
  1129.  For /F "UsebackQ tokens=2" %%G in ("%TEMP%\PID.dat")Do (
  1130.   Set "querry=powershell -nologo -noprofile -command gwmi Win32_Process -filter 'processid = %%G' ^| select ParentProcessId"
  1131.   For /f "Skip=2 Tokens=1,2 Delims=- " %%I in ('!Querry!')Do (
  1132.    Set "ParentProcessID=%%I"
  1133.   )
  1134.  )
  1135.  Del "%TEMP%\PID.dat"
  1136.  Endlocal & Set "ParentProcessID=%ParentProcessID%"
  1137.  
  1138.  set "ProcessType=0"
  1139.  set "ParentProcessName="
  1140.  
  1141.  > nul 2>&1 Set "WT_SESSION" && (
  1142.   set "ProcessType=3"
  1143.   set "ParentProcessName=WindowsTerminal.exe"
  1144.  )
  1145.  
  1146.  If Defined ParentProcessID (
  1147.   For /F "Skip=1 tokens=1 delims=," %%G in ('Tasklist /FI "PID EQ %ParentProcessID%" /FO CSV')Do If %ProcessType% EQU 0 (
  1148.    If /I not "%%~G"=="cmd.exe" (
  1149.     Set "ParentProcessName=%%~G"
  1150.    )Else Set "ParentProcessName=%%~G"
  1151.   ) Else If /I "%%~G"=="cmd.exe" If %ProcessType% EQU 3 (
  1152.    Set "ProcessType=2"
  1153.    Set "ParentProcessName=%%~G child of WindowsTerminal.exe"
  1154.   )
  1155.  )
  1156.  
  1157.  If /I "%ParentProcessName%"=="Explorer.exe" Set "ProcessType=1"
  1158.  If /I not "%ParentProcessName%" == "cmd.exe" If %ProcessType% EQU 0 Set "ProcessType=-1"
  1159.  
  1160.  Exit /b %ProcessType%
  1161.  
  1162. :TestVT
  1163.  Set "VTsupport="
  1164.  2> nul (
  1165.   More < "%~f0:VTsupport" > nul && (
  1166.    Exit /b 0
  1167.   ) || (
  1168.    <Nul Set /P "=Verifying Compatability %\E%[2D"
  1169.    for /F "delims=" %%a in ('"PowerShell $console=$Host.UI.RawUI; $curPos=$console.CursorPosition; $rect=new-object System.Management.Automation.Host.Rectangle $curPos.X,$curPos.Y,$curPos.X,$curPos.Y; $BufCellArray=$console.GetBufferContents($rect); Write-Host $BufCellArray[0,0].Character;"') do (
  1170.     Cls
  1171.     If "%%a" == "y" (
  1172.      (Echo(true) >"%~f0:VTsupport"
  1173.      Exit /b 0
  1174.     )else (
  1175.      Echo(Virtual terminal sequences not enabled on your system. This program will not execute as intended.
  1176.      Exit /b 1
  1177.  ))))
  1178. Exit /b 2
  1179.  
  1180. ====================
  1181. REM Button Functions
  1182. ====================
  1183.  
  1184. :YesNo      ["Option 1"] ["Prompt 2"] ["Spoken Prompt"]
  1185. REM Default:    Yes           No
  1186.  
  1187.  %Buffer:@=Alt%
  1188.  If not "%~3"=="" start /b "" PowerShell -Nop -ep Bypass -C "Add-Type –AssemblyName System.Speech; (New-Object System.Speech.Synthesis.SpeechSynthesizer).Speak('%~3');
  1189.  
  1190.  If "%~1"=="" %Make.Btn% YN /N /S "Yes" /Y 3 /X 3 /FG 0 0 0 /BG 255 0 0 /BO 38 2 60 0 0 + 48 2 20 20 40
  1191.  If not "%~1"=="" %Make.Btn% YN /N /S "%~1" /Y 3 /X 3 /FG 0 0 0 /BG 255 0 0 /BO 38 2 60 0 0 + 48 2 20 20 40
  1192.  If "%~2"=="" %Make.Btn% YN /S "No" /Y 3 /FG 0 0 0 /BG 0 255 0 /BO 38 2 0 60 0 + 48 2 20 20 40
  1193.  If not "%~2"=="" %Make.Btn% YN /S "%~2" /Y 3 /FG 0 0 0 /BG 0 255 0 /BO 38 2 0 60 0 + 48 2 20 20 40
  1194.  
  1195. :YesNoWait
  1196.  %Get.Click% YN
  1197.  If defined ValidClick[YN] (
  1198.   %Buffer:@=Main%
  1199.  )Else Goto :YesNoWait
  1200.  %If.Btn[YN]%[1] Exit /B 1
  1201.  %If.Btn[YN]%[2] Exit /B 2
  1202.  
  1203. =========
  1204. :ColorMod <Prefixvar.Extension> [-l]
  1205. :# Prefix var doubles as the name of the Alternate data stream color variables as saved to / loaded from
  1206. :# values returned:
  1207. :# prefixvar.ext.FG.Color prefixvar.ext.BG.Color
  1208. :# prefixvar.ext_FG_Red prefix.var_FG_Blue prefix.var_FG_Green
  1209. :# prefixvar.ext_BG_Red prefix.var_BG_Blue prefix.var_BG_Green
  1210. :#
  1211.  %Buffer:@=Alt%
  1212.  If Not "%~1" == "" Set "Type=%~1"
  1213.  
  1214. :# load any existing saved values.
  1215.  (For /F "UsebackQ Delims=" %%G in ("%~f0:%Type%")Do %%G) 2> nul
  1216.  If /I "%~2"=="-l" Goto :Eof
  1217.  
  1218.  If "!%Type%_FG_Red!"=="" If "!%Type%_BG_Red!"=="" (
  1219.   For %%Z in ("FG" "BG")Do (
  1220.    If not defined %Type%.%%~Z.Color (
  1221.     Cls & Echo(Defalut value for %Type%.%%~Z.Color must be defined in format rrr;ggg;bbb
  1222.     Pause
  1223.     Exit
  1224.    )
  1225.    For /F "Tokens=1,2,3 Delims=;" %%1 in ("!%Type%.%%~Z.Color!")Do (
  1226.     Set "%Type%_%%~Z_Red=%%1"
  1227.     Set "%Type%_%%~Z_Green=%%2"
  1228.     Set "%Type%_%%~Z_Blue=%%3"
  1229.  )))
  1230.  
  1231.  If "!%Type%_Zone!" == "" Set "%Type%_Zone=BG"
  1232.  If "!%Type%_Spectrum!" == "" Set "%Type%_Spectrum=%Type%_!%Type%_Zone!_Blue"
  1233.  
  1234. :# definition of /d switch assigns default toggle state to last stored value; or default value if no value stored.
  1235.  
  1236. %= [CMcolor][1] =%       %Make.btn% CMcolor /s Red /y 3 /x 3 /fg 255 0 0 /bg 0 0 0 /bo 48 2 0 0 0 + 38 2 255 255 255 /tm /cd %Type%_Spectrum /N
  1237. %= [CMcolor][2] =%       %Make.btn% CMcolor /s Green /y 3 /fg 0 255 0 /bg 0 0 0 /bo 48 2 0 0 0 + 38 2 255 255 255 /tm /cd %Type%_Spectrum
  1238. %= [CMcolor][3] =%       %Make.btn% CMcolor /s Blue /y 3 /fg 0 0 255 /bg 0 0 0 /bo 48 2 0 0 0 + 38 2 255 255 255 /tm /cd %Type%_Spectrum
  1239.  
  1240. %= [CMzone][1] =%        %Make.btn% CMzone /s FG /y 6 /x 3 /tm /bo 48 2 0 0 0 + 38 2 255 255 255 /cd %Type%_Zone /N
  1241. %= [CMzone][2] =%        %Make.btn% CMzone /s BG /y 6 /x 7 /bo 48 2 0 0 0 + 38 2 255 255 255 /tm /cd %Type%_Zone
  1242.  
  1243. %= [CMcontrol][2] =%         %Make.btn% CMcontrol /s " ▲   " /y 6 /x 11 /fg 255 255 255 /bg 50 20 50 /bo 33 /N
  1244. %= [CMcontrol][3] =%         %Make.btn% CMcontrol /s " ▼   " /y 6 /fg 255 255 255 /bg 50 20 50 /bo 33
  1245. %= [CMcontrol][1] =%         %Make.btn% CMcontrol /s "     Accept       " /bg 180 160 0 /bo 32 /y 9 /x 3
  1246.  
  1247. :ColorModLoop
  1248.  Set "%Type%.FG.Color=!%Type%_FG_Red!;!%Type%_FG_Green!;!%Type%_FG_Blue!"
  1249.  Set "%Type%.BG.Color=!%Type%_BG_Red!;!%Type%_BG_Green!;!%Type%_BG_Blue!"
  1250.  
  1251.  <nul Set /P "=%\E%[13d%\E%[G%\E%[38;2;255;255;255m%\E%[48;2;!%Type%.BG.Color!m%Type% FG: %\E%[38;2;!%Type%.FG.Color!m!%Type%_FG_Red!;!%Type%_FG_Green!;!%Type%_FG_Blue! %\E%[38;2;255;255;255mBG:%\E%[38;2;!%Type%.FG.Color!m!%Type%_BG_Red!;!%Type%_BG_Green!;!%Type%_BG_Blue!%\E%[0m%\E%[K"
  1252.  
  1253.  %Get.Click% CMzone CMcolor CMcontrol
  1254.  If not defined Group Goto :ColorModLoop
  1255.  
  1256.  If not "%Group%" == "CMcontrol" %Toggle.If.Not% !ValidClick[%Group%]!
  1257.  
  1258.  If "%Group%"=="CMzone" (
  1259.   Set "%Type%_Zone=!Clicked[%Group%]!"
  1260.   If "!Clicked[%Group%]!"=="FG" (
  1261.    Set "%Type%_Spectrum=!%Type%_Spectrum:BG=FG!"
  1262.   )Else Set "%Type%_Spectrum=!%Type%_Spectrum:FG=BG!"
  1263.  )
  1264.  
  1265.  If "%Group%"=="CMcolor" Set "%Type%_Spectrum=%Type%_!%Type%_Zone!_!Clicked[%Group%]!"
  1266.  
  1267.  For /f "Delims=" %%G in ("!%Type%_Spectrum!") Do (
  1268.   %If.Btn[CMcontrol]%[1] (
  1269.    If not !%%G! EQU 255 ( Set /A "%%G+=5" )Else Start /b "" %BG.exe% play "%WINDIR%\Media\Windows Error.wav"
  1270.   )
  1271.   %If.Btn[CMcontrol]%[2] (
  1272.    If not !%%G! EQU 0 ( Set /A "%%G-=5" )Else Start /b "" %BG.exe% play "%WINDIR%\Media\Windows Error.wav"
  1273.  ))
  1274.  
  1275. :# Update stored Color values in alternate data stream
  1276.  (For /f "Delims=" %%G in ('Set %Type%')Do Echo(Set "%%G") >"%~f0:%Type%"
  1277.  
  1278.  %If.Btn[CMcontrol]%[3] (
  1279.   %Buffer:@=Main%
  1280.   Goto :Eof
  1281.  )
  1282.  
  1283. Goto :ColorModLoop
  1284.  
  1285.  
  1286. ==========
  1287. :ShowState <GroupName>
  1288.  %Buffer:@=Alt%
  1289.  For %%G in (%*)Do (
  1290.   For /l %%i in (1 1 !Btns[%%~G][i]!)Do If defined Btn[%%~G][%%i]{t} Echo(Btn[%%~G][%%i]{state}=!Btn[%%~G][%%i]{state}!
  1291.  )
  1292.  Timeout /T 15
  1293.  %Buffer:@=Main%
  1294.  Cls
  1295. Goto :eof
  1296.  
  1297. ==========================
  1298. :# REQUIRED UTILITY BG.exe
  1299. :# - Allows mouse click to be accepted [ blocking input ]
  1300. :# - Allows .Wav files to be played
  1301. :# - Refer to the documentation at the github repository for all usage options. [ link below ]
  1302.  
  1303. /* BG.exe V 3.9
  1304.   https://github.com/carlos-montiers/consolesoft-mirror/blob/master/bg/README.md
  1305.   Copyright (C) 2010-2018 Carlos Montiers Aguilera
  1306.  
  1307.   This software is provided 'as-is', without any express or implied
  1308.   warranty.  In no event will the authors be held liable for any damages
  1309.   arising from the use of this software.
  1310.  
  1311.   Permission is granted to anyone to use this software for any purpose,
  1312.   including commercial applications, and to alter it and redistribute it
  1313.   freely, subject to the following restrictions:
  1314.  
  1315.   1. The origin of this software must not be misrepresented; you must not
  1316.      claim that you wrote the original software. If you use this software
  1317.      in a product, an acknowledgment in the product documentation would be
  1318.      appreciated but is not required.
  1319.   2. Altered source versions must be plainly marked as such, and must not be
  1320.      misrepresented as being the original software.
  1321.   3. This notice may not be removed or altered from any source distribution.
  1322.  
  1323.   Carlos Montiers Aguilera
  1324.   cmontiers@gmail.com
  1325.  */
  1326.  
  1327. -----BEGIN CERTIFICATE-----
  1328. TVqQAAMAAAAEAAAA//8AALgAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  1329. AAAAAAAAAAAAAAAAgAAAAA4fug4AtAnNIbgBTM0hVGhpcyBwcm9ncmFtIGNhbm5v
  1330. dCBiZSBydW4gaW4gRE9TIG1vZGUuDQ0KJAAAAAAAAABQRQAATAEEAG3tp1sAAAAA
  1331. AAAAAOAADwMLAQIZABoAAAAIAAAAAgAAcCcAAAAQAAAAAMD/AABAAAAQAAAAAgAA
  1332. BAAAAAEAAAAEAAAAAAAAAABgAAAABAAAu00AAAMAAAAAACAAABAAAAAAEAAAEAAA
  1333. AAAAABAAAAAAAAAAAAAAAABQAABMBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  1334. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  1335. AAAAAAAAAAD4UAAAlAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC50ZXh0AAAA
  1336. IBkAAAAQAAAAGgAAAAQAAAAAAAAAAAAAAAAAACAAUGAucmRhdGEAALgBAAAAMAAA
  1337. AAIAAAAeAAAAAAAAAAAAAAAAAABAAGBALmJzcwAAAACMAAAAAEAAAAAAAAAAAAAA
  1338. AAAAAAAAAAAAAAAAgABgwC5pZGF0YQAATAQAAABQAAAABgAAACAAAAAAAAAAAAAA
  1339. AAAAAEAAMMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  1340. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  1341. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  1342. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  1343. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  1344. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  1345. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  1346. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  1347. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  1348. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  1349. AAAAAAAAAAAAAAAAAAAAAFWJ5YPsGKFQUUAAg8AgiUQkBA+3RQiJBCToIhgAAMnD
  1350. hcAPhBoBAABVieVXVlOJx4PsPA+3GGaF2w+E/AAAADH2x0XQAAAAADHJ6ziNdCYA
  1351. Mclmg/tcD5TBdBqhUFFAAIkcJIlN1IPAIIlEJATozhcAAItN1IPHAg+3H2aF2w+E
  1352. jAAAAIXJdMgPt8PHRCQEgAAAAIkEJIlF1OiaFwAAhcAPhKoAAACDfdABD45wAQAA
  1353. g/5/iXXkD7fGD4+RAQAAixVQUUAAiQQkg8cCMfaNSiCJTCQE6GcXAAChUFFAAIPA
  1354. IIlEJASLRdSJBCToUBcAAA+3HzHJx0XQAAAAAGaF23WD6w2QkJCQkJCQkJCQkJCQ
  1355. i0XQhcB0JIP+f4l13A+3xg+PygEAAIsVUFFAAIkEJIPCIIlUJAToBRcAAI1l9Fte
  1356. X13zw422AAAAAI2/AAAAAItV0IXSdGmD/n+JdeAPt8YPj0oBAACLFVBRQACJBCSN
  1357. SiCJTCQE6MUWAAAxyWaD+1wPlMEPhIYAAAChUFFAAIlNzDH2g8AgiUQkBItF1IkE
  1358. JOiaFgAAx0XQAAAAAItNzOnA/v//jXQmAI28JwAAAABmg/tuD4R2AQAAD4awAAAA
  1359. ZoP7cg+ERgEAAGaD+3QPhXwBAAChUFFAAMcEJAkAAACDwCCJRCQE6EQWAAAxyely
  1360. /v//jbYAAAAAjbwnAAAAADH2x0XQAAAAAOlX/v//ZpCDRdABweYEZoP7OQ+GrwAA
  1361. AIPLIA+3w4PoVwHGuQEAAADpL/7//412AI28JwAAAACNRdzHRCQIAQAAAIlEJASN
  1362. ReSJBCT/FXxRQAAPt0Xcg+wM6Uj+//+J9o28JwAAAABmg/tiD4XWAAAAoVBRQADH
  1363. BCQIAAAAg8AgiUQkBOieFQAAMcnpzP3//420JgAAAACNRdzHRCQIAQAAAIlEJASN
  1364. ReCJBCT/FXxRQAAPt0Xcg+wM6Y/+//+J9o28JwAAAACLRdSD6DDpT////5CNdCYA
  1365. jUXax0QkCAEAAACJRCQEjUXciQQk/xV8UUAAD7dF2oPsDOkP/v//ifaNvCcAAAAA
  1366. oVBRQADHBCQNAAAAg8AgiUQkBOgIFQAAMcnpNv3//5ChUFFAAMcEJAoAAACDwCCJ
  1367. RCQE6OgUAAAxyekW/f//kKFQUUAAg8AgiUQkBItF1IkEJOjJFAAAMcnp9/z//2aQ
  1368. oUhAQACD+AJ+OlWJ5VdWU4PsHIsVREBAAIP4A4tyCHUvx0QkCBIAAgDHRCQEAAAA
  1369. AIk0JP8VhFFAAIPsDI1l9FteX13zw412AI28JwAAAADHRCQICgAAAMdEJAQAAAAA
  1370. i0IMiQQk6DUUAACFwH7Oiz2EUUAAjVj/kI20JgAAAACD6wHHRCQIEgACAMdEJAQA
  1371. AAAAiTQk/9eD7AyD+/914OubjbQmAAAAAI28JwAAAABVuAQAAAC6BgAAALkGAAAA
  1372. ieVXVlO+CAAAALsIAAAAvwgAAACB7LwAAABmiYVs////uBAAAABmiYV4////uAgA
  1373. AACDPUhAQAADZomFev///7gFAAAAZomVbv///2aJhXz///+4DAAAAGaJjXD///9m
  1374. iYV+////uAcAAABmiZ1y////ZolFgLgMAAAAZom1dP///2aJRYK4EAAAAGaJvXb/
  1375. //9miUWOuAoAAAC6CAAAALkMAAAAuxAAAAC+DAAAAL8MAAAAZolFkLgSAAAAZolV
  1376. hGaJTYZmiV2IZol1imaJfYxmiUWSdAmNZfRbXl9dw5ChREBAAMdEJAgKAAAAx0Qk
  1377. BAAAAACLQAiJBCTo4BIAAIP4CYnDd9DHRCQYAAAAAMdEJBQAAAAAx0QkEAMAAADH
  1378. RCQMAAAAAMdEJAgDAAAAx0QkBAAAAMDHBCQAMEAA/xX8UEAAg+wcicbHBCQQMEAA
  1379. /xUcUUAAg+wEhcCJxw+ElgAAAMdEJAQqMEAAiQQk/xUYUUAAg+wIhcCJhWT///90
  1380. bA+3hJ1s////jU2Ux0QkBEIwQADHRZRUAAAAiV2YiY1g////x0WgMAAAAMdFpJAB
  1381. AABmiUWcD7eEnW7///9miUWejUWoiQQk6BsSAACLjWD////HRCQEAAAAAIk0JIuV
  1382. ZP///4lMJAj/0oPsDIk8JP8VBFFAAIPsBIlcJASJNCToWxIAAIPsCIk0JP8V+FBA
  1383. AIPsBOm+/v//jbQmAAAAAFWJ5VZTjXXwg+wwx0QkGAAAAADHRCQUAAAAAMdEJBAD
  1384. AAAAx0QkDAAAAADHRCQIAwAAAMdEJAQAAADAxwQkADBAAP8V/FBAAIPsHInDiXQk
  1385. BIkEJP8VCFFAAIPsCIM9SEBAAAN0OsdF9AEAAADHRfAZAAAAiXQkBIkcJP8VJFFA
  1386. AIPsCIkcJP8V+FBAAIPsBI1l+FteXcOJ9o28JwAAAAChREBAAMdEJAgKAAAAx0Qk
  1387. BAAAAACLQAiJBCToABEAAIP4GXQlfxmFwHQlg/gBdaTHRfQBAAAA65uNtCYAAAAA
  1388. g/gydAWD+GR1iolF8OvhkMdF9AAAAADpeP///410JgCDPUhAQAADdAfDjbYAAAAA
  1389. VYnlg+wYoURAQADHRCQICgAAAMdEJAQAAAAAi0AIiQQk6IoQAACFwH4MiQQk/xU4
  1390. UUAAg+wEycOQjbQmAAAAAFWJ5YPsSI1F6IkEJP8VFFFAAA+3RfaD7ATHBCRUMEAA
  1391. iUQkIA+3RfSJRCQcD7dF8olEJBgPt0XwiUQkFA+3Re6JRCQQD7dF6olEJAwPt0Xo
  1392. iUQkCA+3ReyJRCQE6AcQAADJw422AAAAAI28JwAAAABVieVXVlONfcyNddSD7FzH
  1393. RCQYAAAAAMdEJBQAAAAAx0QkEAMAAADHRCQMAAAAAMdEJAgDAAAAx0QkBAAAAMDH
  1394. BCSGMEAA/xX8UEAAicONRdCD7ByJHCSJRCQE/xUMUUAAi0XQg+wIiRwkJC4MkIlE
  1395. JAShMFFAAIlFxP/Qg+wIkIl8JAzHRCQIAQAAAIl0JASJHCT/FSBRQACD7BBmg33U
  1396. AnXdg33cAXXXD7912g+/fdjHBCSUMEAAiXQkBIl8JAjB5hDoMA8AAItF0IkcJAH+
  1397. iUQkBP9VxIPsCIkcJP8V+FBAAIPsBIk0JP8VAFFAAJBVieVTg+wEix1MUUAA/9OF
  1398. wHQdPeAAAAB0FqNAQEAAg8QEW13DjXQmAI28JwAAAAD/0wUAAQAAo0BAQACDxARb
  1399. XcONtCYAAAAAjbwnAAAAAFWJ5VOD7AT/FVRRQACFwHUfxwVAQEAAAAAAAIPEBFtd
  1400. w+sNkJCQkJCQkJCQkJCQkIsdTFFAAP/ThcB0FD3gAAAAdA2jQEBAAIPEBFtdw2aQ
  1401. /9MFAAEAAOvqjbQmAAAAAIM9SEBAAAR0B8ONtgAAAABVieVXVlOD7FzHRCQYAAAA
  1402. AMdEJBQAAAAAx0QkEAMAAADHRCQMAAAAAMdEJAgDAAAAx0QkBAAAAMDHBCQAMEAA
  1403. /xX8UEAAicaNRdKD7ByJNCSJRCQE/xUQUUAAoURAQACD7AgPt33gx0QkCAoAAADH
  1404. RCQEAAAAAA+3XeJmK33ci0AIZitd3okEJOjCDQAAiUXEoURAQADHRCQICgAAAMdE
  1405. JAQAAAAAi0AMiQQk6J8NAACLVcQxyWaFwA9IwYk0JGaF0g9I0WY5xw9P+GY50w9P
  1406. 2g+3/8HjEAn7iVwkBP8VKFFAAIPsCIk0JP8V+FBAAIPsBI1l9FteX13DjbYAAAAA
  1407. VYnlU4PsJMdEJBgAAAAAx0QkFAAAAADHRCQQAwAAAMdEJAwAAAAAx0QkCAMAAADH
  1408. RCQEAAAAwMcEJAAwQAD/FfxQQACD7ByDPUhAQAADicO4BwAAAHQpiRwkiUQkBP8V
  1409. NFFAAIPsCIkcJP8V+FBAAItd/IPsBMnDkI20JgAAAAChREBAAMdEJAgQAAAAx0Qk
  1410. BAAAAACLQAiJBCTosAwAAA+3wOuyjXQmAI28JwAAAAChSEBAAIP4BX8G88ONdCYA
  1411. VYPoAYnlV1ZTg+x8iUWkx0QkGAAAAADHRCQUAAAAAMdEJBADAAAAx0QkDAAAAADH
  1412. RCQIAwAAAMdEJAQAAADAxwQkADBAAP8V/FBAAInDjUXSg+wciRwkiUQkBP8VEFFA
  1413. AKFEQEAAg+wIx0QkCAoAAADHRCQEAAAAAItACIkEJOgMDAAAicahREBAAMdEJAgK
  1414. AAAAx0QkBAAAAACLQAyJBCTo6gsAAGajIEBAAGajPEBAAA+3ReCJHSxAQABmK0Xc
  1415. Zok1IkBAAMdFqBQAAADHRawEAAAAZqMwQEAAD7dF4mYrRd5mozJAQAC4AQAAAGaj
  1416. NEBAALgBAAAAZqM2QEAAMcBmozhAQAAxwGajOkBAAKE8UUAAiUWgifaNvCcAAAAA
  1417. i32soURAQADHRCQIEAAAAMdEJAQAAAAAiwS4iQQk6E0LAACJ+WajKkBAAKFEQEAA
  1418. g8ECiU2si02oizQIhfYPhEkBAAAPtx5mhdsPhD0BAAAx/8dFtAAAAAAx0utSjXYA
  1419. MdJmg/tcD5TCdDVmhdsPhAwCAABmg/sKD4XCAQAAD7cFPEBAAGaDBSJAQAABZqMg
  1420. QEAAjbYAAAAAjbwnAAAAAIPGAg+3HmaF2w+EoQAAAIXSdK0Pt9PHRCQEgAAAAIkU
  1421. JIlVsOi/CgAAhcAPhN8AAACDfbQBi1WwD44iAgAAg/9/iX3MifoPj0QDAABmhdIP
  1422. hLsCAABmg/oKD4UxAgAAD7cFPEBAAGaDBSJAQAABZoP7CmajIEBAAA+FrAIAAA+3
  1423. BTxAQABmgwUiQEAAAYPGAjH/MdLHRbQAAAAAZqMgQEAAD7ceZoXbD4Vi////jXYA
  1424. i0W0hcB0NoP/f4l9xIn4D4+rBQAAZoXAD4RiBQAAZoP4Cg+FuAQAAA+3BTxAQABm
  1425. gwUiQEAAAWajIEBAAINFqAiLTaw5TaQPj2P+//+NZfRbXl9dw410JgCNvCcAAAAA
  1426. i0W0hcAPhNUAAACD/3+JfciJ+g+PNwQAAGaF0g+EDgMAAGaD+goPhYQCAAAPtwU8
  1427. QEAAZoMFIkBAAAFmoyBAQAAx0maD+1wPlMIPhCACAABmhdsPhHcDAABmg/sKD4Xt
  1428. AgAAD7cFPEBAAGaDBSJAQAABMf/HRbQAAAAAZqMgQEAA6Wr+//+NdgCNvCcAAAAA
  1429. D7cFIEBAAGaFwHgkZjsFMEBAAH8bD7cNIkBAAGaFyXgPZjsNMkBAAA+OwgUAAGaQ
  1430. g8ABZqMgQEAA6SL+//9mkGaDBSBAQAAB6RP+//+NdgBmg/tuD4RWBAAAD4YAAwAA
  1431. ZoP7cg+ElgQAAGaD+3QPhSwFAAAPtwUgQEAAZoXAeDBmOwUwQEAAfycPtxUiQEAA
  1432. ZoXSeBtmOxUyQEAAD44GBgAAjbQmAAAAAI28JwAAAACDwAEx0majIEBAAOmg/f//
  1433. g0W0AcHnBIPqMGaD+zl2CYPLIA+304PqVwHXugEAAADpe/3//410JgCNvCcAAAAA
  1434. D7cFIEBAAGaFwHh7ZjsFMEBAAH9yD7cNIkBAAGaFyXhmZjsNMkBAAH9dg8ABg8EB
  1435. ZokVKEBAAGajJEBAAKE4QEAAZokNJkBAAMdEJBAgQEAAx0QkBChAQACJRCQMoTRA
  1436. QACJRCQIoSxAQACJBCT/FTxRQACD7BSJ9o28JwAAAAAPtwUgQEAAg8ABZoP7Cmaj
  1437. IEBAAA+EVP3//2aFwHgxZjkFMEBAAHwoD7cVIkBAAGaF0ngcZjsVMkBAAA+OngQA
  1438. AOsNkJCQkJCQkJCQkJCQkIPAATH/MdJmoyBAQADHRbQAAAAA6Yf8//+NtCYAAAAA
  1439. Mf/HRbQAAAAA6XL8//9mkI1FwsdEJAgBAAAAiUQkBI1FzIkEJP8VfFFAAA+3VcKD
  1440. 7Azplfz//4n2jbwnAAAAAA+3BSBAQABmhcB4e2Y7BTBAQAB/cg+3DSJAQABmhcl4
  1441. ZmY7DTJAQAB/XYPAAYPBAWaJFShAQABmoyRAQAChOEBAAGaJDSZAQADHRCQQIEBA
  1442. AMdEJAQoQEAAiUQkDKE0QEAAiUQkCKEsQEAAiQQk/xU8UUAAg+wUifaNvCcAAAAA
  1443. D7cFIEBAAIPAAWajIEBAAOn8/P//jXQmAI28JwAAAABmhcB4e2Y5BTBAQAB8cg+3
  1444. DSJAQABmhcl4ZmY7DTJAQAB/XYPAAYPBAYlVtGajJEBAAKE4QEAAZokdKEBAAGaJ
  1445. DSZAQADHRCQQIEBAAMdEJAQoQEAAiUQkDKE0QEAAiUQkCKEsQEAAiQQk/xU8UUAA
  1446. D7cFIEBAAItVtIPsFI12AIPAATH/x0W0AAAAAGajIEBAAOkJ+///ifaNvCcAAAAA
  1447. ZoP7Yg+FNgIAAA+3BSBAQABmhcAPiDb9//9mOwUwQEAAD48p/f//D7cVIkBAAGaF
  1448. 0g+IGf3//2Y7FTJAQAAPjwz9//+5CAAAAGaJDShAQADp/wIAAI10JgCNvCcAAAAA
  1449. jUXCx0QkCAEAAACJRCQEjUXIiQQk/xV8UUAAD7dVwoPsDOmi+///ifaNvCcAAAAA
  1450. D7cVIEBAAGaF0nh0ZjsVMEBAAH9rD7cNIkBAAGaFyXhfZjsNMkBAAH9WZqMoQEAA
  1451. oThAQACDwgGDwQFmiRUkQEAAx0QkECBAQABmiQ0mQEAAx0QkBChAQACJRCQMoTRA
  1452. QACJRCQIoSxAQACJBCT/FTxRQAAPtxUgQEAAg+wUZpCDwgGDRagIi02sOU2kZokV
  1453. IEBAAA+PNvn//+nO+v//kGaDBSBAQAABg0WoCItNrDlNpA+PGPn//+mw+v//jXYA
  1454. D7cFPEBAAGaDBSJAQAABMdJmoyBAQADplPn//410JgCNRcLHRCQIAQAAAIlEJASN
  1455. RcSJBCT/FXxRQAAPt0XCg+wM6S76//+J9o28JwAAAAAPtwUgQEAAZoXAD4ig+///
  1456. ZjsFMEBAAA+Pk/v//w+3FSJAQABmhdIPiIP7//9mOxUyQEAAD492+///g8ABg8IB
  1457. uw0AAABmoyRAQAChOEBAAGaJHShAQABmiRUmQEAAx0QkECBAQADHRCQEKEBAAIlE
  1458. JAyhNEBAAIlEJAihLEBAAIkEJP9VoA+3BSBAQACD7BTpG/v//410JgCNvCcAAAAA
  1459. ZoP7Cg+EBv///w+3BSBAQABmhcAPiPb6//9mOwUwQEAAD4/p+v//D7cVIkBAAGaF
  1460. 0g+I2fr//2Y7FTJAQAAPj8z6//9miR0oQEAA6cQAAACDwAGDwQGJVbBmoyRAQACh
  1461. OEBAAGaJHShAQABmiQ0mQEAAx0QkECBAQADHRCQEKEBAAIlEJAyhNEBAAIlEJAih
  1462. LEBAAIkEJP8VPFFAAA+3BSBAQACD7BSLVbDp4fn//4PAAYPCAWaJHShAQABmoyRA
  1463. QAChOEBAAGaJFSZAQADHRCQQIEBAAMdEJAQoQEAAiUQkDKE0QEAAiUQkCKEsQEAA
  1464. iQQk/xU8UUAAD7cFIEBAAIPsFOkY+///uQkAAABmiQ0oQEAAg8ABg8IBx0QkECBA
  1465. QABmoyRAQAChOEBAAGaJFSZAQADHRCQEKEBAAIlEJAyhNEBAAIlEJAihLEBAAIkE
  1466. JP8VPFFAAA+3BSBAQACD7BTpqvn//412AI28JwAAAABVieVXVlOD7FzHRCQEojBA
  1467. AMcEJAAAAADoEwIAAKFQUUAAg8AgiQQk/xVIUUAAx0QkBAAAAgCJBCT/FVhRQACh
  1468. SEBAAIP4Aw+EAwEAAH8RjWX0W15fXcOJ9o28JwAAAACD6AHHRCQYAAAAAMdEJBQA
  1469. AAAAiUXAx0QkEAMAAAC7DAAAAMdEJAwAAAAAx0QkCAMAAAC/AgAAAMdEJAQAAADA
  1470. xwQkADBAAP8V/FBAAInCiUXEjUXSg+wciUQkBIkUJP8VEFFAAIPsCJCNtCYAAAAA
  1471. oURAQADHRCQIEAAAAMdEJAQAAAAAiwS4g8cCiQQk6C0BAACLDURAQAAPt8CLNBmJ
  1472. RCQEg8MIi0XEiQQk/xU0UUAAifCD7AjoBOn//zl9wH+vD7dF2ot1xIk0JIlEJAT/
  1473. FTRRQACD7AiJNCT/FfhQQACD7ASNZfRbXl9dw410JgChREBAAItACOjD6P//6e3+
  1474. //+NtCYAAAAAjbwnAAAAAFWJ5VdWU41F5IPsPMdF5AAAAACJRCQQx0QkDAAAAADH
  1475. RCQIAEBAAMdEJAREQEAAxwQkSEBAAOjFAAAAhcB4S4M9SEBAAAF+NKFEQEAAizVc
  1476. UUAAMduLeASQjbQmAAAAAIsE3UAxQACJPCSJRCQE/9aFwHQjg8MBg/sMdeShQEBA
  1477. AIkEJP8VAFFAAMcEJP//////FQBRQAD/FN1EMUAA69z/JYRRQACQkP8ldFFAAJCQ
  1478. /yVwUUAAkJD/JWxRQACQkP8laFFAAJCQ/yVkUUAAkJD/JWBRQACQkP8lXFFAAJCQ
  1479. /yVYUUAAkJD/JVRRQACQkP8lTFFAAJCQ/yVIUUAAkJD/JURRQACQkP8lfFFAAJCQ
  1480. /yU8UUAAkJD/JThRQACQkP8lNFFAAJCQ/yUwUUAAkJD/JSxRQACQkP8lKFFAAJCQ
  1481. /yUkUUAAkJD/JSBRQACQkP8lHFFAAJCQ/yUYUUAAkJD/JRRRQACQkP8lEFFAAJCQ
  1482. /yUMUUAAkJD/JQhRQACQkP8lBFFAAJCQ/yUAUUAAkJD/JfxQQACQkP8l+FBAAJCQ
  1483. /////wAAAAD/////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  1484. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  1485. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  1486. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  1487. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  1488. QwBPAE4ATwBVAFQAJAAAAEsARQBSAE4ARQBMADMAMgAuAEQATABMAAAAU2V0Q3Vy
  1489. cmVudENvbnNvbGVGb250RXgAVABlAHIAbQBpAG4AYQBsAAAAJQBkACAAJQBkACAA
  1490. JQBkACAAJQBkACAAJQBkACAAJQBkACAAJQBkACAAJQBkAAoAAABDAE8ATgBJAE4A
  1491. JAAAACUAZAAgACUAZAAKAAAAAABQAFIASQBOAFQAAABGAEMAUABSAEkATgBUAAAA
  1492. QwBPAEwATwBSAAAATABPAEMAQQBUAEUAAABMAEEAUwBUAEsAQgBEAAAASwBCAEQA
  1493. AABNAE8AVQBTAEUAAABEAEEAVABFAFQASQBNAEUAAABTAEwARQBFAFAAAABDAFUA
  1494. UgBTAE8AUgAAAEYATwBOAFQAAABQAEwAQQBZAAAAAACkMEAAACZAALAwQACAG0AA
  1495. wDBAANAaQADMMEAAwBlAANowQABgGUAA6jBAABAZQADyMEAAIBhAAP4wQACwF0AA
  1496. EDFAAGAXQAAcMUAAYBZAACoxQAAwFEAANDFAAIATQABHQ0M6ICh0ZG02NC0xKSA1
  1497. LjEuMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  1498. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABkUAAAAAAAAAAAAADcUwAA
  1499. +FAAALBQAAAAAAAAAAAAACBUAABEUQAA6FAAAAAAAAAAAAAAMFQAAHxRAADwUAAA
  1500. AAAAAAAAAABAVAAAhFEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAjFEAAJpRAACoUQAA
  1501. tlEAAMRRAADcUQAA7lEAAAxSAAAcUgAALlIAAD5SAABSUgAAalIAAIZSAACYUgAA
  1502. qlIAAMRSAADMUgAAAAAAAOJSAAD0UgAA/lIAAAhTAAAQUwAAGlMAACZTAAAyUwAA
  1503. PFMAAEhTAABUUwAAXlMAAGhTAAAAAAAAclMAAAAAAACEUwAAAAAAAIxRAACaUQAA
  1504. qFEAALZRAADEUQAA3FEAAO5RAAAMUgAAHFIAAC5SAAA+UgAAUlIAAGpSAACGUgAA
  1505. mFIAAKpSAADEUgAAzFIAAAAAAADiUgAA9FIAAP5SAAAIUwAAEFMAABpTAAAmUwAA
  1506. MlMAADxTAABIUwAAVFMAAF5TAABoUwAAAAAAAHJTAAAAAAAAhFMAAAAAAABTAENs
  1507. b3NlSGFuZGxlAJIAQ3JlYXRlRmlsZVcAGgFFeGl0UHJvY2VzcwBkAUZyZWVMaWJy
  1508. YXJ5AKQBR2V0Q29uc29sZUN1cnNvckluZm8AALABR2V0Q29uc29sZU1vZGUAALYB
  1509. R2V0Q29uc29sZVNjcmVlbkJ1ZmZlckluZm8AAAQCR2V0TG9jYWxUaW1lAABFAkdl
  1510. dFByb2NBZGRyZXNzAAAsA0xvYWRMaWJyYXJ5VwAApQNSZWFkQ29uc29sZUlucHV0
  1511. VwDzA1NldENvbnNvbGVDdXJzb3JJbmZvAAD1A1NldENvbnNvbGVDdXJzb3JQb3Np
  1512. dGlvbgAA9wNTZXRDb25zb2xlRm9udAAAAQRTZXRDb25zb2xlTW9kZQAACgRTZXRD
  1513. b25zb2xlVGV4dEF0dHJpYnV0ZQB0BFNsZWVwAOwEV3JpdGVDb25zb2xlT3V0cHV0
  1514. VwB3AF9fd2dldG1haW5hcmdzAAAFAV9maWxlbm8AOwFfZ2V0Y2gAAGEBX2lvYgAA
  1515. xAFfa2JoaXQAALUCX3NldG1vZGUAAI0DX3djc2ljbXAAAEsEZnB1dHdjAAB1BGlz
  1516. d2N0eXBlAACqBHNldGxvY2FsZQD0BHdjc2NweQAABwV3Y3N0b2wAAA4Fd3ByaW50
  1517. ZgDIAU9lbVRvQ2hhckJ1ZmZXAAAJAFBsYXlTb3VuZFcAAAAAAFAAAABQAAAAUAAA
  1518. AFAAAABQAAAAUAAAAFAAAABQAAAAUAAAAFAAAABQAAAAUAAAAFAAAABQAAAAUAAA
  1519. AFAAAABQAAAAUAAAS0VSTkVMMzIuZGxsAAAAABRQAAAUUAAAFFAAABRQAAAUUAAA
  1520. FFAAABRQAAAUUAAAFFAAABRQAAAUUAAAFFAAABRQAABtc3ZjcnQuZGxsAAAoUAAA
  1521. VVNFUjMyLmRsbAAAPFAAAFdJTk1NLkRMTAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  1522. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  1523. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  1524. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  1525. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  1526. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  1527. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  1528. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  1529. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  1530. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
  1531. -----END CERTIFICATE-----
  1532.  
  1533. ==============================
  1534. :ButtonsMain Script body - USAGE DEMO
  1535. ==============================
  1536.  
  1537. :# Enable Macros; facilitate nested variables !element[%index%]!
  1538.  Setlocal enableDelayedExpansion
  1539.  
  1540. :# Ensure no Existing variables prefixed 'Btn'
  1541.  For /f "Tokens=1,2 Delims==" %%G in ('Set Btn 2^> nul')Do Set "%%G="
  1542.  
  1543.  Set /A "Density=4", "minX=5", "maxX=45", "minY=5", "maxY=20"
  1544.  Set "Live.Cell.Char=╬"
  1545.  Set "Live.Cell.Char[i]=20"
  1546.  
  1547.  For %%z in (Live Dead)Do Call :ColorMod %%z.cell -l
  1548.  
  1549.  If "!Live.Cell.FG.Color!"=="" Set "Live.Cell.FG.Color=250;70;0"
  1550.  If "!Live.Cell.BG.Color!"=="" Set "Live.Cell.BG.Color=0;80;160"
  1551.  If "!Dead.Cell.FG.Color!"=="" Set "Dead.Cell.FG.Color=20;30;40"
  1552.  If "!Dead.Cell.BG.Color!"=="" Set "Dead.Cell.BG.Color=0;0;0"
  1553.  
  1554. %= [demo][1] =% %Make.Btn% demo /S Option One /t
  1555. %= [demo][2] =% %Make.Btn% demo /S Option Two /t
  1556. %= [demo][3] =% %Make.Btn% demo /S Option Three /t
  1557. %= [demo][4] =% %Make.Btn% demo /S "    Exit      " /bo 38 2 190 160 0 + 48 2 40 0 0 /bg 40 0 0 /fg 40 200 40
  1558.  
  1559. :Demoloop REM [ demo -  Generic menu via a loop ]
  1560. REM redefines buttons each loop with current color values. Note /N switch used to reset
  1561. REM button group.
  1562. %= [CellCol][1] =% %Make.Btn% CellCol /S Live.Cell /X 20/fg %!!% /bg %!!% /bo 33 /N
  1563. %= [CellCol][2] =% %Make.Btn% CellCol /S Dead.Cell /fg %!!% /bg %!!% /bo 33
  1564.  
  1565. REM Expand Get.Click macro with arguments corresponding to the group names of buttons defined using make.btn
  1566. REM Each loop Displays Buttons current toggle state. Use goto to break out of a loop to your target label.
  1567.  %Get.Click% demo CellCol
  1568.  
  1569.  Title Y;X:!C{pos}! C:!Clicked[%Group%]! VC:!ValidClick[%Group%]!
  1570.  %If.btn[demo]%[4] (
  1571.   Call :YesNo Yes No "Are you sure?"
  1572.   If "!Clicked[YN]!" == "Yes" (
  1573.    cls
  1574.   REM [ demo - Familiarise users with state definitions for toggle buttons. ]
  1575.    Set btn[ | findstr /lic:"{state}"
  1576.    Pause
  1577.    %Clean.Exit%
  1578.   )
  1579.  )
  1580.  
  1581. Rem assess If button clicked belonged to a specific group, if true Passes the buttons text to the Function ColorMod
  1582.  If "%Group%"=="CellCol" Call :ColorMod !Clicked[CellCol]!
  1583.  
  1584. Goto :Demoloop
Add Comment
Please, Sign In to add comment