T3RRYT3RR0R

Buttons macro with detailed help

Jun 30th, 2021 (edited)
1,314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 49.52 KB | None | 0 0
  1. :Buttons ================== Macro definitions and exe creation to facilitate Button Input.
  2. @Echo off
  3. REM ** IMPORTANT NOTE: WINDOWS 11 has different Virtual terminal Syntax which broke this script.
  4. REM scipt has been updated to resolve this issue, by replacing previous supported Syntax for moving cursor
  5. REM up \EA down \EB Left \ED right \EC with explicit values: up \E[1A down \E[1B Left \E[1D right \E[1C
  6.  
  7. :# As exampled at: https://youtu.be/ZYhvUbek4Xc
  8.  
  9. :# Batch clickable button macros and example functions
  10. :# Author: T3RRY Version: 2.0.5 Last Update: 11/01/2022
  11. :# New features:
  12. :# Added 'def' arg to allow this file to be called to define macros for use in a calling file.
  13. :#  - Note:
  14. :#        - Delayed Expansion be DISabled prior to defining macros
  15. :#        - Delayed Expansion must be ENabled to expand macros
  16. :# Expanded help information
  17. :# Reduced number of macros and functions to simplify usage
  18. :# Added new switches to make.btn for controlling button toggle type and defaults
  19. :# Added prompt for permission to install bg.exe ; a required component of this file.
  20.  
  21. :testEnviron
  22.  If "!!" == "" (Goto :button_help)
  23.  Set "Buttons_File=%~f0"
  24.  
  25. (Set \n=^^^
  26.  
  27. %= \n macro newline variable. Do not modify =%)
  28. (Set LF=^
  29.  
  30.  
  31. %= LF newline variable. Do not modify =%)
  32.  
  33. CLS
  34.  
  35. ====================:# OS Requirement tests
  36. :# Verify NTFS drive ** ADS Used to store Settings applied in demo function ColorMod
  37.  (Echo(verify.NTFS >"%~f0:Status") || (
  38.   Echo(This file must be located on an NTFS drive as it utilises Alternate Data Streams.
  39.   Pause
  40.   Exit /B 1
  41.  )
  42.  
  43.  For /f "Delims=" %%e in ('Echo(Prompt $E^|cmd')Do Set "\E=%%~e"
  44.  
  45.  Call:TestVT || Exit /B 1
  46.  
  47. :# Buttons macro Based on function at: https://www.dostips.com/forum/viewtopic.php?f=3&t=9222
  48.  
  49. :# Script Structure:
  50. :# OS and Exe Validation
  51. :# - Variable and macro Setup
  52. :#  - Functions
  53. :#   - Macro help handling
  54. :#    - [Script Break - Jump to :Main]
  55. :#     - Embedded Exe for Mouse and Key Inputs
  56. :#      - Main script body
  57.  
  58.  Set "reg.restore=(Call )"
  59.  
  60. :# disable QuickEdit if enabled. Restored at :end label if disabled by script
  61.   For /f "skip=1 Tokens=3" %%G in ('reg query HKEY_CURRENT_USER\console\ /v Quickedit')Do Set "QE.reg=%%G"
  62.    If "%QE.reg%" == "0x1" (
  63.    (Reg add HKEY_CURRENT_USER\console\ /v QuickEdit /t REG_DWORD /d 0x0 /f) > nul
  64.    Set "reg.restore=Reg add HKEY_CURRENT_USER\console\ /v QuickEdit /t REG_DWORD /d 0x1 /f"
  65.   )
  66.  
  67.  If not exist "%TEMP%\BG.exe" (
  68.   Echo(%\E%[33mThis program requires Bg.exe to run.%\E%[0m
  69.   Echo( Install from this file %\E%[32m[Y]%\E%[0m or Exit %\E%[31m[N]%\E%[0m ?
  70.   For /f "delims=" %%C in ('%SystemRoot%\System32\choice.exe /N /C:YN')Do if %%C==Y (
  71.    Certutil -decode "%~f0" "%TEMP%\BG.exe" > nul
  72.   )Else Exit /B 1
  73.   Cls
  74.  )
  75.  
  76.  Set BG.exe="%TEMP%\BG.exe"
  77.  
  78.  For /f "tokens=4 Delims=: " %%C in ('CHCP')Do Set "active.cp=%%C"
  79.  chcp 65001 > nul
  80.  
  81.  Set "/??=0"
  82. :#0  \E33m
  83. :#0 Call this file with one of the below macro or function \E37mNames\E33m
  84. :#0 to see it's full usage information.
  85. :#0  \E36m
  86. :#0 Macros: \E37m
  87. :#0  Make.Btn   \E38;2;61;61;61m %Make.Btn% GroupName /S button text \E37m
  88. :#0  Get.Click  \E38;2;61;61;61m %Get.Click% GroupName OtherGroupName \E37m
  89. :#0  If.Btn     \E38;2;61;61;61m %If.Btn[Groupname]%[#] command \E37m
  90. :#0  Buffer     \E38;2;61;61;61m %Buffer:@=Alt% \E37m
  91. :#0             \E38;2;61;61;61m %Buffer:@=Main% \E37m
  92. :#0  Clean.Exit \E38;2;61;61;61m %Clean.Exit%
  93. :#0  \E36m
  94. :#0 Functions: \E37m
  95. :#0  YesNo      \E38;2;61;61;61m Call :YesNo "Option 1" "Option 2" "Spoken Prompt"
  96. :#0  \E36m
  97. :#0 Define macros for use in a calling .bat or .cmd script: \E37m
  98. :#0  Call buttons.bat def
  99. :#0
  100.  
  101.  Set "Buffer?=1"
  102. :#1 \E36m
  103. :#1 Usage:   %Buffer:@=Alt%
  104. :#1 \E0m          - Switch to Alt buffer; preserving content of main screen buffer.
  105. :#1 \E36m
  106. :#1          %Buffer:@=Main%
  107. :#1 \E0m          - Returns to main screen buffer.
  108. :#1
  109.  Set "Buffer.Hash=@"
  110.  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)"
  111.  Set "Alt=%\E%[?1049h%\E%[?25l"
  112.  Set "Main=%\E%[?25h%\E%[?1049l%\E%[?25l"
  113.  
  114. :# button sound fx. disable by undefining buttonsfx below ; prior to definition of OnCLick macro
  115.  Set "buttonsfx=On"
  116.  %BG.exe% Play "%WINDIR%\Media\Windows Feed Discovered.wav"
  117.  Set "OnClick=(Call )"
  118.  Set "OnType=(Call )"
  119.  If defined buttonsfx (
  120.   For /f "Delims=" %%G in ('Dir /b /s "%WINDIR%\SystemApps\*KbdKeyTap.wav"')Do If exist "%%~G" Set "OnClick=(Start /b "" %BG.exe% Play "%%~G")"
  121.   Set "OnType=(start /b "" %BG.exe% Play "%WINDIR%\Media\Windows Feed Discovered.wav")"
  122.  )
  123.  
  124.  Set "Get.Click?=2"
  125. :#2 \E36m
  126. :#2 Usage: %Get.Click% \E0m{^<\E31mGroupName\E0m^> ^| ^<\E31mGroupName\E0m^> ^<\E31mOtherGroupName\E0m^>}
  127. :#2 \E33m
  128. :#2 Performs the following Actions: \E0m
  129. :#2  - Launches Bg.exe with mouse arg to get mouse click
  130. :#2  - Assigns 1 indexed Y;X pos of mouse click to c{Pos}
  131. :#2  - Performs a conditional comparison via substring modifications
  132. :#2    of all buttons Coordinates defined in each btn[GroupName] array
  133. :#2    matching against the Y;X value of c{Pos}
  134. :#2 \E33m
  135. :#2 On clicked position matching a buttons defined Coordinates: \E0m
  136. :#2  - If %Make.Btn% /T or /TM Switches used to define defined btn[Groupname][Index]{t}:
  137. :#2    - /T:
  138. :#2      - Toggles button visually by inverting colors
  139. :#2      - Toggles btn[Groupname][Index]{state} variable value: true / false
  140. :#2    - /TM:
  141. :#2      - Forces btn[Groupname][Index]{state} true for clicked button.
  142. :#2      * Use In conjunction with /D 'default' or /CD 'Conditional Default' switch
  143. :#2        when a mandatory single selection is required.
  144. :#2  - Defines the following:
  145. :#2     If.btn[GroupName]=\E35mIf [Groupname][Index] == [GroupName]\E0m
  146. :#2     Group=GroupName
  147. :#2     Clicked[Groupname]=Button Text
  148. :#2     ValidClick[GroupName]=[GroupName][Index]
  149. :#2     - Tip reference values directly using: \E36m
  150. :#2       !Clicked[%Group%]!
  151. :#2       !ValidClick[%Group%]!  \E0m
  152. :#2  - Plays the system file KbdKeyTap.wav [If Present] as a clicking sound.
  153. :#2 \E33m
  154. :#2 On clicked position not matching a buttons defined Coordinates: \E0m
  155. :#2  - Defines:
  156. :#2     If.btn[GroupName]=\E36mIf Not.Clicked ==\E0m
  157. :#2  - Undefined:
  158. :#2     Group
  159. :#2      - To loop to a label and wait for a valid click of any
  160. :#2        button defined to a supplied GroupName, Use:
  161. :#2        \E36mIf not defined Group Goto :\E33mlabel\E0m
  162. :#2     Clicked[Groupname]
  163. :#2     ValidClick[GroupName]
  164. :#2
  165.  Set "If.Btn?=4"
  166. :#4 \E36m
  167. :#4 Usage: %If.btn\E35m[GroupName]\E36m%\E31m[Index] \E90m(Command)\E0m
  168. :#4
  169. :#4  -\E33m Compares clicked button \E0m[GroupName][Index]\E33m against \E0m[Groupname]\E31m[arg]\E0m
  170. :#4
  171.  
  172. :# return button click coords in c{pos} variable n Y;X format
  173.  Set Get.Click=For %%n in (1 2)Do if %%n==2 (%\n%
  174.   Set "Group="%\n%
  175.   For %%G in (!GroupName!)Do (%\n: Update display of toggle state =%
  176.    For /l %%i in (1 1 !Btns[%%G][i]!)Do (%\n%
  177.     If not "!Btn[%%G][%%i]{state}!"=="true" (%\n%
  178.      ^<nul set /P "=!Btn[%%G][%%i]!"%\n%
  179.     )Else If Defined Btn[%%G][%%i]{t} (%\n%
  180.      set "tmpstr=!Btn[%%G][%%i]:38=7;38!"%\n%
  181.      ^<nul set /P "=!tmpstr:48=7;48!"%\n%
  182.   )))%\n%
  183.   for /f "tokens=1,2" %%X in ('%BG.exe% mouse')Do (%\n: Wait for mouse input =%
  184.    Set /A "c{pos}=%%X+1"                         %\n: Adjust X axis for 1 index =%
  185.    Set "c{pos}=!c{Pos}!;%%Y"                     %!!%
  186.    For %%G in (!GroupName!)Do (                  %\n: iterate over list of supplied group names =%
  187.     Set "If.Btn[%%G]=If Not.Clicked =="          %\n: assign or clear default values for return variables =%
  188.     Set "Clicked[%%G]="%\n%
  189.     Set "ValidClick[%%G]="%\n%
  190.     Set "ValidClick[%%G]{t}="%\n%
  191.     For /F "Delims=" %%C in ("!c{Pos}!")Do (     %\n: expand Coordinate var for use in substring modification =%
  192.      For /l %%I in (1 1 !btns[%%G][I]!)Do (      %\n: test if [Y;X] Coord contained in btn Coord Var =%
  193.       If not "!btn[%%G][%%I][Coord]:[%%C]=!" == "!btn[%%G][%%I][Coord]!" (%\n%
  194.        %OnClick%                                 %\n: play click sound effect if available =%
  195.        Set "Group=%%G"                           %\n: assign groupname value the button clicked belongs to =%
  196.        Set "If.Btn[%%G]=If [%%G][%%I] == [%%G]"  %\n: define If.Btn[GroupName] macro =%
  197.        Set "ValidClick[%%G]=[%%G][%%I]"          %\n: assign [GroupName][Index] of clicked button =%
  198.        Set "Clicked[%%G]=!Btn[%%G][%%I][String]!"%\n: assign the text containd in the clicked button =%
  199.        If Defined Btn[%%G][%%I][items] (%\n%
  200.         Set Btn[%%G][%%I][items]="!Btn[%%G][%%I][items]:{EQ}==!"%\n%
  201.         Set "Btn[%%G][%%I][items]=!Btn[%%G][%%I][items]: =" "!"%\n%
  202.         Set "Tmp.Items=!Btn[%%G][%%I][items]!"%\n%
  203.         Set "Btn[%%G][%%I][items]="%\n%
  204.         For %%t in (!Tmp.Items!)Do (%\n%
  205.          Set "tmp.str=%%~t"%\n%
  206.          Set "tmp.str=!tmp.Str:_= !"%\n%
  207.          Set "!tmp.str!"%\n%
  208.          Echo(!tmp.str!^|findstr.exe /R "[0-9]" ^> nul ^|^| Set "Btn[%%G][%%I][items]=!Btn[%%G][%%I][items]! "!tmp.str!""%\n%
  209.         )%\n%
  210.        )%\n%
  211.        If Defined Btn[%%G][%%I]{t} (             %\n: toggle state handling. =%
  212.         Set "ValidClick[%%G]{t}=[%%G][%%I]"      %\n: flag toggle state change for toggle.If.Not macro =%
  213.         If "!Btn[%%G][%%I]{state}!"=="true" (    %\n: update console display of toggle state by inverting colors =%
  214.         If not defined Btn[%%G][%%I]{m} (%\n%
  215.          ^<nul set /P "=!Btn[%%G][%%I]!"%\n%
  216.           Set "Btn[%%G][%%I]{state}=false"%\n%
  217.          )%\n%
  218.         )Else (%\n%
  219.          set "tmpstr=!Btn[%%G][%%I]:38=7;38!"%\n%
  220.          ^<nul set /P "=!tmpstr:48=7;48!"%\n%
  221.          Set "Btn[%%G][%%I]{state}=true"%\n%
  222.   )))))))%\n%
  223.  )Else Set GroupName=
  224.  
  225.  Set "Toggle.If.not?=5"
  226. :#5 \E36m
  227. :#5 Usage: %Toggle.If.Not% \E0m{^<\E31m[Groupname][Index]\E0m^> ^| ^<\E31m[Groupname][Index]\E0m^> ^<\E31m[OtherGroupname][Index]\E0m^>}
  228. :#5 \E33m
  229. :#5 Macro Actions: \E0m
  230. :#5 - Defines {state} false for all toggle buttons in GroupName except [Groupname][Index]
  231. :#5 - Updates Display Color of all buttons; Inverting each button with {state}=true
  232. :#5
  233. :#5 * Multiple [GroupName][Index]'s \E31m with unique GroupNames \E0m may be supplied
  234. :#5 \E33m
  235. :#5 Example usage:\E36m
  236. :#5 %Toggle.If.Not% !ValidClick[GroupName]!
  237. :#5 \E0m
  238.  Set Toggle.If.not=For %%n in (1 2)Do if %%n==2 (%\n%
  239.   For /f "tokens=1,2 Delims=[]" %%G in ("!GroupName: =!")Do (%\n: Remove spaces from arg assignment =%
  240.    If defined ValidClick[%%G]{t} (               %\n: If state change flagged true in Get.Click macro =%
  241.     For /l %%i in (1 1 !btns[%%G][i]!)Do (       %\n: test each button in groupname =%
  242.      If not "%%i"=="%%H" (                       %\n: If not button EQU clciked button =%
  243.       Set "btn[%%G][%%i]{state}=false"           %\n: Force btn[%%G][%%i]{state} false =%
  244.       ^<nul Set /P "=!btn[%%G][%%i]!"            %\n: Display button in standard unselected color =%
  245.   ))))%\n%
  246.  )Else Set GroupName=
  247.  
  248.  Set "Clean.Exit?=7"
  249. :#7
  250. :#7 Clean.Exit \E33m
  251. :#7  Restores codepage and Quickedit registry state
  252. :#7  Clears the title and screen ; ends the local environment
  253. :#7  executes Goto :Eof
  254. :#7 \E0m
  255.  Set Clean.Exit=(%\n%
  256.   cls %\n%
  257.   (%Reg.Restore%) ^> nul %\n%
  258.   (Title ) %\n%
  259.   ^<nul set /p "=%\E%[?25h" %\n%
  260.   CHCP %active.cp% ^> nul %\n%
  261.   Endlocal %\n%
  262.   Goto :Eof %\n%
  263.  )
  264.  
  265.  Set "Make.Btn?=9"
  266. :#9  \E33m
  267. :#9 Make.Btn Macro Usage: \E36m
  268. :#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]
  269. :#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]
  270. :#9            [^<\E31m/TM\E0m^> [\E32m/D\E0m]^|[\E32m/CD Variable\E0m]]
  271. :#9  \E37m
  272. :#9  - Arg 1 must be Groupname. Switch order is NOT mandatory.
  273. :#9  \E36m
  274. :#9   /N \E37mReset button count for GroupName (Arg 1) to 0. use when creating buttons in a :label that is returned to. \E36m
  275. :#9   /T \E37mDefine button as toggleable. Button state: 'Btn[Groupname][i]{state}' variable
  276. :#9      alternates true or false when clicked; and clicked buttons Color is inverted on match. \E36m
  277. :#9   /TM \E0m'Toggle Mandatory' as above; however mandatory true state for last selected button \E36m
  278. :#9      /D  \E0m'default selection' ; Flags toggle {state} true on definition. \E31m * Requires \E36m/TM
  279. :#9      /CD \E0m'Conditional default selection' ; If /CD Variable contains /S string
  280. :#9           Flags toggle {state} true on definition. \E31m * Requires \E36m/TM
  281. :#9
  282. :#9 Note: \E36m/BO \E37m{'Button box'} may supply a pair of R G B values for FG and BG by concatenating values with '+'
  283. :#9   IE: '\E36m/BO \E38;2;255;0;0m\E48;2;0;0;100m38 2 255 0 0 + 48 2 0 0 100\E0m'
  284. :#9   R G B sequences are groups of three integers between 0 and 255. Each R G B value adjusts the intensity of
  285. :#9  that color. Valid values for Virtual terminal sequences can be referenced at:
  286. :#9  \E32m https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences#text-formatting
  287. :#9  \E33m
  288. :#9 Default Y and X Coordinates is used are /X value is ommited \E37m
  289. :#9 - Button defaults to next X spacing if /Y position included ; Else X = 2
  290. :#9 - Button defaults to next Y spacing if /Y ommited ;
  291. :#9   - defaults to previous /X spacing if /X also ommited
  292. :#9
  293. :#9 \E38;2;81;81;81mExpansion time is approxiamtely 1/33rd of a second when all switches used.
  294. :#9 \E0m
  295.  
  296.  Set Make.Btn[Switches]="S" "Y" "X" "FG" "BG" "BO" "T" "TM" "D" "N" "CD" "Def"
  297.  
  298.  Set Make.Btn=For %%n in (1 2)Do if %%n==2 (                              %\n: CAPTURE ARG STRING =%
  299.   Set "Make.Btn[Syntax]=%\E%[33m!Make.Btn[args]!"%\n%
  300.   For /F "Tokens=1,2 Delims==" %%G in ('Set "Make.Btn_" 2^^^> nul')Do Set "%%~G=" %\n: RESETS ALL MACRO INTERNAL VARS =%
  301.   If not "!Make.Btn[args]:* /=!" == "!Make.Btn[args]!" (                              %\n: BUILD Make.Btn.Args[!Make.Btn_arg[i]!] ARRAY IF ARGS PRESENT =%
  302.    Set "Make.Btn_leading.args=!Make.Btn[args]:*/=!"                                   %\n: SPLIT ARGS FROM SWITCHES =%
  303.    For /F "Delims=" %%G in ("!Make.Btn_leading.args!")Do Set "Make.Btn_leading.args=!Make.Btn[args]:/%%G=!"%\n%
  304.    Set ^"Make.Btn[args]=!Make.Btn[args]:"=!"                                          %\n: REMOVE DOUBLEQUOTES FROM REMAINING ARGSTRING - SWITCHES =%
  305.    Set "Make.Btn_arg[i]=0"                                                            %\n: ZERO INDEX FOR ARGS ARRAY =%
  306.    For %%G in (!Make.Btn_leading.args!)Do (                                           %\n: BUILD ARGS ARRAY =%
  307.     Set /A "Make.Btn_arg[i]+=1"%\n%
  308.     Set "Make.Btn_arg[!Make.Btn_arg[i]!]=%%~G"%\n%
  309.     For %%i in ("!Make.Btn_arg[i]!")Do (                                              %\n: SUBSTITUTE THE FOLLOWING POISON CHARACTERS =%
  310.      Set "Make.Btn_arg[%%~i]=!Make.Btn_arg[%%~i]:{SC}=;!"%\n%
  311.      Set "Make.Btn_arg[%%~i]=!Make.Btn_arg[%%~i]:{QM}=?!"%\n%
  312.      Set "Make.Btn_arg[%%~i]=!Make.Btn_arg[%%~i]:{FS}=/!"%\n%
  313.      Set "Make.Btn_arg[%%~i]=!Make.Btn_arg[%%~i]:{AS}=*!"%\n%
  314.      Set "Make.Btn_arg[%%~i]=!Make.Btn_arg[%%~i]:{EQ}==!"%\n%
  315.      Set ^"Make.Btn_arg[%%~i]=!Make.Btn_arg[%%~i]:{DQ}="!"%\n%
  316.   ))) Else (                                                                           %\n: IF NO ARGS REMOVE DOUBLEQUOTES FROM ARGSTRING - SWITCHES =%
  317.    Set ^"Make.Btn[args]=!Make.Btn[args]:"=!"%\n%
  318.    Set "Make.Btn_Arg[1]=!Make.Btn[args]!"%\n%
  319.    Set "Make.Btn_Arg[i]=1"%\n%
  320.   )%\n%
  321.   For /L %%L in (2 1 4)Do If "!Make.Btn_LastSwitch!" == "" (%\n%
  322.    If "!Make.Btn[args]:~-%%L,1!" == " " Set "Make.Btn_LastSwitch=_"%\n%
  323.    If "!Make.Btn[args]:~-%%L,1!" == "/" (                                              %\n: FLAG LAST SWITCH TRUE IF NO SUBARGS ; FOR SWITCHES UP TO 3 CHARCTERS LONG =%
  324.     For /F "Delims=" %%v in ('Set /A "%%L-1"')Do Set "Make.Btn_Switch[!Make.Btn[args]:~-%%v!]=true"%\n%
  325.     If not "!Make.Btn[args]:/?=!." == "!Make.Btn[args]!." Set "Make.Btn_Switch[help]=true"%\n%
  326.     Set "Make.Btn[args]=!Make.Btn[args]:~0,-%%L!"%\n%
  327.     Set "Make.Btn_LastSwitch=_"%\n%
  328.    )%\n%
  329.   )%\n%
  330.   For %%G in ( %Make.Btn[Switches]% )Do If not "!Make.Btn[args]:/%%~G =!" == "!Make.Btn[args]!" (%\n: SPLIT AND ASSIGN SWITCH VALUES =%
  331.    Set "Make.Btn_Switch[%%~G]=!Make.Btn[args]:*/%%~G =!"%\n%
  332.    If not "!Make.Btn_Switch[%%~G]:*/=!" == "!Make.Btn_Switch[%%~G]!" (%\n%
  333.     Set "Make.Btn_Trail[%%~G]=!Make.Btn_Switch[%%~G]:*/=!"%\n%
  334.     For %%v in ("!Make.Btn_Trail[%%~G]!")Do (%\n%
  335.      Set "Make.Btn_Switch[%%~G]=!Make.Btn_Switch[%%~G]: /%%~v=!"%\n%
  336.      Set "Make.Btn_Switch[%%~G]=!Make.Btn_Switch[%%~G]:/%%~v=!"%\n%
  337.     )%\n%
  338.     Set "Make.Btn_Trail[%%~G]="%\n%
  339.     If "!Make.Btn_Switch[%%~G]:~-1!" == " " Set "Make.Btn_Switch[%%~G]=!Make.Btn_Switch[%%~G]:~0,-1!"%\n%
  340.     If "!Make.Btn_Switch[%%~G]!" == "" Set "Make.Btn_Switch[%%~G]=true"%\n%
  341.     If not "!Make.Btn_Switch[%%~G]!" == "" If not "!Make.Btn_Switch[%%~G]!" == "true" (%\n%
  342.      Set "Make.Btn_Switch[%%~G]=!Make.Btn_Switch[%%~G]:{SC}=;!"%\n%
  343.      Set "Make.Btn_Switch[%%~G]=!Make.Btn_Switch[%%~G]:{QM}=?!"%\n%
  344.      Set "Make.Btn_Switch[%%~G]=!Make.Btn_Switch[%%~G]:{FS}=/!"%\n%
  345.      Set "Make.Btn_Switch[%%~G]=!Make.Btn_Switch[%%~G]:{AS}=*!"%\n%
  346.      Set "Make.Btn_Switch[%%~G]=!Make.Btn_Switch[%%~G]:{EQ}==!"%\n%
  347.      Set ^"Make.Btn_Switch[%%~G]=!Make.Btn_Switch[%%~G]:{DQ}="!"%\n%
  348.    ))%\n%
  349.    If "!Make.Btn_Switch[%%~G]:~-1!" == " " Set "Make.Btn_Switch[%%~G]=!Make.Btn_Switch[%%~G]:~0,-1!"%\n%
  350.   )%\n: ACTION SWITCH ASSESSMENT BELOW. USE CONDITIONAL TESTING OF VALID SWITCHES OR ARGS ARRAY TO ENACT COMMANDS FOR YOUR MACRO FUNCTION =%
  351.   If not defined Make.Btn_Arg[1] (%\n:           Enforce button Groupname Definiton via Arg 1 =%
  352.    Call "%Buttons_File%" Make.Btn%\n%
  353.    ^<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%
  354.    Pause %\n%
  355.    cls %\n%
  356.    (%Reg.Restore%) ^> nul %\n%
  357.    (Title ) %\n%
  358.    ^<nul set /p "=%\E%[?25h" %\n%
  359.    CHCP %active.cp% ^> nul %\n%
  360.    Endlocal %\n%
  361.    Goto :Eof %\n%
  362.   )%\n%
  363.   If not defined Make.Btn_Switch[S] (%\n:        Enforce button text definition via /S switch parameter value =%
  364.    Call "%Buttons_File%" Make.Btn%\n%
  365.    ^<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%
  366.    Pause %\n%
  367.    cls %\n%
  368.    (%Reg.Restore%) ^> nul %\n%
  369.    (Title ) %\n%
  370.    ^<nul set /p "=%\E%[?25h" %\n%
  371.    CHCP %active.cp% ^> nul %\n%
  372.    Endlocal %\n%
  373.    Goto :Eof %\n%
  374.   )%\n%
  375.   For %%e in ("!Make.Btn_Arg[1]!")Do (%!!%
  376.    If defined Make.Btn_Switch[N] (%\n:           Reset button group index and X Y positions if /N switch used =%
  377.     Set "Btn[%%~e][X]="%\n%
  378.     Set "Btn[%%~e][Y]="%\n%
  379.     Set "Btns[%%~e][i]=0"%\n%
  380.    )%\n%
  381.    If defined Make.Btn_Switch[Y] (%\n:           Determine button Y Position according to /Y switch usage or default increment =%
  382.     Set /A "Btn[%%~e][Y]=!Make.Btn_Switch[Y]!"%\n%
  383.    )Else (%\n%
  384.     Set /A "Btn[%%~e][Y]+=3+0"%\n%
  385.    )%\n%
  386.    If defined Make.Btn_Switch[X] (%\n:           Determine button X Position according to /X usage or default increment =%
  387.     Set /A "Btn[%%~e][X]=!Make.Btn_Switch[X]!"%\n%
  388.    )Else (%\n%
  389.     If defined Make.Btn_Switch[Y] (%\n%
  390.      Set /A "Btn[%%~e][X]=!L[%%~e][X]!+0"%\n%
  391.     )Else (%\n%
  392.      If not defined Btn[%%~e][X] Set "Btn[%%~e][X]=2"%\n%
  393.    ))%\n%
  394.    If !Btn[%%~e][X]! LSS 1 ( Set "Btn[%%~e][X]=1" )%\n: Constrain X min to One =%
  395.    Set /a "Btns[%%~e][i]+=1+0"%\n:               Increment button Index =%
  396.    For %%f in ("!Btns[%%~e][i]!")Do (%\n:        Expand button index =%
  397.     Set "Btn[%%~e][!Btns[%%~e][i]!][p]=!Btn[%%~e][Y]!;!Btn[%%~e][X]!"%\n%
  398.     Set "Btn[%%~e][!Btns[%%~e][i]!][string]=!Make.Btn_Switch[S]!"%\n%
  399.     If /I "!Make.Btn_Switch[T]!"=="true" (%\n:   Define toggle vars according to /T or /TM switche usage =%
  400.      Set "Btn[%%~e][%%~f]{t}=true"%\n%
  401.      Set "Btn[%%~e][%%~f]{state}=false"%\n%
  402.     ) Else If /I "!Make.Btn_Switch[TM]!"=="true" (%\n%
  403.      Set "Btn[%%~e][%%~f]{t}=true"%\n%
  404.      Set "Btn[%%~e][%%~f]{state}=false"%\n%
  405.      Set "Btn[%%~e][%%~f]{m}=true"%\n%
  406.     ) Else (%\n:                                 If /Tor /TM toggle switches not used ; ensure toggle vars undefined =%
  407.      Set "Btn[%%~e][%%~f]{t}="%\n%
  408.      Set "Btn[%%~e][%%~f]{state}="%\n%
  409.      Set "Btn[%%~e][%%~f]{m}="%\n%
  410.     )%\n%
  411.     If defined Make.Btn_Switch[D] (%\n:          Define button as toggle state true =%
  412.      If defined Btn[%%~e][%%~f]{t} (%\n:         if button is defined as toggleable =%
  413.       Set "Btn[%%~e][%%~f]{state}=true"%\n%
  414.     ))%\n%
  415.     If defined Make.Btn_Switch[CD] (%\n:         Test supplied variable for contents of button text =%
  416.      If defined Btn[%%~e][%%~f]{t} (%\n:         if button is defined as toggleable =%
  417.       For %%1 in ("!Make.Btn_Switch[CD]!")Do (%\n%
  418.        For %%2 in ("!Make.Btn_Switch[S]!")Do (%\n%
  419.         If not "!%%~1:%%~2=!"=="!%%~1!" (%\n:     Define button as toggle state true on match =%
  420.          Set "Btn[%%~e][%%~f]{state}=true"%\n%
  421.     )))))%\n%
  422.     If defined Make.Btn_Switch[FG] (%\n:         Assign Foreground color =%
  423.      Set "Btn[%%~e][FG]=%\E%[38;2;!Make.Btn_Switch[FG]: =;!m"%\n%
  424.     )Else (%\n%
  425.      set "Btn[%%~e][FG]=%\E%[38;2;0;0;0m"%\n%
  426.     )%\n%
  427.     Set "Btn[%%~e][%%~f][FG]=!Btn[%%~e][FG]!"%\n%
  428.     Set "Btn[%%~e][%%~f][iFG]=!Btn[%%~e][FG]:[38=48!"%\n%
  429.     If defined Make.Btn_Switch[BG] (%\n%
  430.      Set "Btn[%%~e][BG]=%\E%[48;2;!Make.Btn_Switch[BG]: =;!m"%\n%
  431.     )Else (%\n%
  432.      Set "Btn[%%~e][BG]=%\E%[48;2;230;230;200m"%\n%
  433.     )%\n%
  434.     Set "Btn[%%~e][%%~f][BG]=!Btn[%%~e][BG]!"%\n%
  435.     Set "Btn[%%~e][%%~f][iBG]=!Btn[%%~e][BG]:[48=38!"%\n%
  436.     If defined Make.Btn_Switch[BO] (%\n:         Process value of /BO border color =%
  437.      Set "Btn[%%~e][Col]=!Btn[%%~e][Col]: + =m%\E%[!"%\n%
  438.      Set "Btn[%%~e][Col]=%\E%[!Make.Btn_Switch[BO]: =;!m"%\n%
  439.      Set "Btn[%%~e][Col]=!Btn[%%~e][Col]:+=m%\E%[!"%\n%
  440.      Set "Btn[%%~e][Col]=!Btn[%%~e][Col]:[;=[!"%\n%
  441.      Set "Btn[%%~e][Col]=!Btn[%%~e][Col]:;;=;!"%\n%
  442.      Set "Btn[%%~e][Col]=!Btn[%%~e][Col]:;m=m!"%\n%
  443.     ) Else (%\n:                                 Enact default border color if no value supplied =%
  444.      set "Btn[%%~e][Col]=%\E%[90m"%\n%
  445.     )%\n%
  446.     Set "Btn[%%~e][%%~f][BO]=!Btn[%%~e][Col]!"%\n%
  447.     Set "len="%\n:                               Get string length of button text =%
  448.     Set "tmp.s=#!Make.Btn_Switch[S]!"%\n%
  449.     For %%P in (8192 4096 2048 1024 512 256 128 64 32 16 8 4 2 1) do (%\n%
  450.      If "!tmp.s:~%%P,1!" NEQ "" (%\n%
  451.       Set /a "len+=%%P"%\n%
  452.       Set "tmp.s=!tmp.s:~%%P!"%\n%
  453.     ))%\n%
  454.     Set /A "Btn{Xmin}=!Btn[%%~e][X]!+1", "Btn{Xmax}=!Btn[%%~e][X]!+len", "l[%%~e][X]=!Btn[%%~e][X]!+len+2"%\n%
  455.     Set "Btn[%%~e][%%~f][S]="%\n%
  456.     Set "Btn[%%~e][%%~f][Bar]="%\n%
  457.     Set "Btn[%%~e][%%~f][Coord]="%\n%
  458.     For /l %%i in (!Btn{Xmin}! 1 !Btn{Xmax}!)Do (%\n%
  459.      Set /A "Btn[%%~e][%%~f][Len]=%%i-3", "Xoffset=%%i-1"%\n%
  460.      Set "Btn[%%~e][%%~f][Coord]=!Btn[%%~e][%%~f][Coord]![!Btn[%%~e][Y]!;!Xoffset!]"%\n%
  461.      Set "Btn[%%~e][%%~f][Bar]=!Btn[%%~e][%%~f][Bar]!═"%\n%
  462.      Set "Btn[%%~e][%%~f][S]=!Btn[%%~e][%%~f][S]! "%\n%
  463.     )%\n%
  464.     Set /A "Btn[%%e][Cpos]=!Btn[%%~e][Y]!+2"%\n%
  465.     If defined Make.Btn_Switch[Def] Set "btn[%%~e][%%~f][items]=!Make.Btn_Switch[Def]!"%\n%
  466.     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%
  467.     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%
  468.   ))%\n%
  469.  %= ESCAPE AMPERSANDS AND REDIRECTION CHARACTERS.  =%) Else Set Make.Btn[args]=
  470.  
  471.  <nul set /p "=%\E%[?25l"
  472.  
  473.  If not "%~1" == "" (
  474.   If /I not "%~1" == "def" (
  475.    Goto :button_help
  476.   )Else Exit /b 0
  477.  )
  478.  
  479. ==========
  480.  Goto :BUttonsMain
  481. ==========
  482.  
  483. :# HELP INFO
  484.  
  485. ============
  486. :button_help </?|Function_Name|Macro_Name>
  487.  Set "_D="
  488.  If not "%~1"=="" (
  489.   Setlocal EnableDelayedExpansion
  490.   Set "_D=!%~1?!"
  491.  )
  492.  Endlocal & Set "_D=%_D%"
  493.  
  494.  If not "%~1"=="" (
  495.   If Defined _D (
  496.    Mode 120,45
  497.    (
  498.     Echo(%\E%[36mSyntax: %\E%[0m^<%\E%[31mMandatory%\E%[0m^> [%\E%[32mOptional%\E%[0m] {%\E%[33mMutually^%\E%[0m^|%\E%[33mExclusive%\E%[0m}
  499.     For /f "Tokens=2* Delims=%_D%" %%T in ('Findstr /BLIC:":#%_D%" "%Buttons_File%"')Do (
  500.      Set "line=%%T"
  501.      Call Set "line=%%line:buttons.bat="%~f0"%%"
  502.      Call Echo(%%Line:\E=%\E%[%%
  503.     )
  504.    )> "%TEMP%\%~n0_Help"
  505.    Type "%TEMP%\%~n0_Help" > Con
  506.    Exit /B -1
  507.   )Else (
  508.    Findstr /BLIC:":%~1 " "%~f0" >nul && (
  509.     Echo(%\E%[36mSyntax: %\E%[0m^<%\E%[31mMandatory%\E%[0m^> [%\E%[32mOptional%\E%[0m] {%\E%[33mMutually^%\E%[0m^|%\E%[33mExclusive%\E%[0m}
  510.     <nul Set /P "=%\E%[K %~1 Usage:%\E%[2E Call "
  511.     Findstr /BLIC:":%~1 " "%Buttons_File%"
  512.     Exit /B -1
  513.    ) || (
  514.     Echo(Help query '%~1' does not match any existing Macro or Function.
  515.     Echo(Check your Spelling and try again.
  516.     Exit /B -1
  517.    )
  518.   )
  519.  )Else (
  520.   Echo(%\E%[33mDelayed Expansion %\E%[31mmust not %\E%[33mbe enabled prior to running %\E%[36m%~nx0%\E%[0m
  521.   Exit /B -1
  522.  )
  523. Goto :eof
  524.  
  525. :TestHost ====================== Identify parent environment
  526. REM function a derivitive of the method proposed by Mathieu at:
  527. REM  https://discord.com/channels/288498150145261568/931201474338357300
  528.  
  529.  Setlocal EnableDelayedExpansion
  530.  
  531.  Set "ParentProcessID="
  532.  wmic process get parentprocessid,name |find "WMIC" 1>"%TEMP%\PID.dat"
  533.  
  534.  For /F "UsebackQ tokens=2" %%G in ("%TEMP%\PID.dat")Do (
  535.   Set "querry=powershell -nologo -noprofile -command gwmi Win32_Process -filter 'processid = %%G' ^| select ParentProcessId"
  536.   For /f "Skip=2 Tokens=1,2 Delims=- " %%I in ('!Querry!')Do (
  537.    Set "ParentProcessID=%%I"
  538.   )
  539.  )
  540.  Del "%TEMP%\PID.dat"
  541.  Endlocal & Set "ParentProcessID=%ParentProcessID%"
  542.  
  543.  set "ProcessType=0"
  544.  set "ParentProcessName="
  545.  
  546.  > nul 2>&1 Set "WT_SESSION" && (
  547.   set "ProcessType=3"
  548.   set "ParentProcessName=WindowsTerminal.exe"
  549.  )
  550.  
  551.  If Defined ParentProcessID (
  552.   For /F "Skip=1 tokens=1 delims=," %%G in ('Tasklist /FI "PID EQ %ParentProcessID%" /FO CSV')Do If %ProcessType% EQU 0 (
  553.    If /I not "%%~G"=="cmd.exe" (
  554.     Set "ParentProcessName=%%~G"
  555.    )Else Set "ParentProcessName=%%~G"
  556.   ) Else If /I "%%~G"=="cmd.exe" If %ProcessType% EQU 3 (
  557.    Set "ProcessType=2"
  558.    Set "ParentProcessName=%%~G child of WindowsTerminal.exe"
  559.   )
  560.  )
  561.  
  562.  If /I "%ParentProcessName%"=="Explorer.exe" Set "ProcessType=1"
  563.  If /I not "%ParentProcessName%" == "cmd.exe" If %ProcessType% EQU 0 Set "ProcessType=-1"
  564.  
  565.  Exit /b %ProcessType%
  566.  
  567. :TestVT
  568. REM test if console is hosted via windows terminal, differentiate between a cmd.exe instance that is a child process of wt.exe
  569. REM bg.exe does not behave as intended when executed from windows terminal.
  570. REM Windows Terminal behaviour       - Does not consistenly flag the release of mouse button click as the end of the input stream.
  571. REM  - expected behavior for cmd.exe - Read mouse input only while mouse button is depressed.
  572. REM impact: Returns input on mouse position change event as well as mouse click event after first click.
  573. REM         The Buttons macro system is designed to act as a script blocking input method and prevent furthor execution
  574. REM         until a click event occurs. In the Windows terminal environment, the button would be deemed as clicked
  575. REM         as soon as the mouse is moved over its location, instead of when the button is clicked.
  576.  Call:TestHost
  577.  If Errorlevel 3 (
  578.   Echo(This script will not work correctly in windows terminal.
  579.   Pause
  580.   Exit /B 1
  581.  )
  582.  Set "VTsupport="
  583.  2> nul (
  584.   More < "%~f0:VTsupport" > nul && (
  585.    Exit /b 0
  586.   ) || (
  587.    <Nul Set /P "=Verifying Compatability %\E%[2D"
  588.    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 (
  589.     Cls
  590.     If "%%a" == "y" (
  591.      (Echo(true) >"%~f0:VTsupport"
  592.      Exit /b 0
  593.     )else (
  594.      Echo(Virtual terminal sequences not enabled on your system. This program will not execute as intended.
  595.      Exit /b 1
  596.  ))))
  597. Exit /b 2
  598.  
  599. ====================
  600. REM Button Functions
  601. ====================
  602.  
  603. :YesNo      ["Option 1"] ["Prompt 2"] ["Spoken Prompt"]
  604. REM Default:    Yes           No
  605.  
  606.  %Buffer:@=Alt%
  607.  If not "%~3"=="" start /b "" PowerShell -Nop -ep Bypass -C "Add-Type –AssemblyName System.Speech; (New-Object System.Speech.Synthesis.SpeechSynthesizer).Speak('%~3');
  608.  
  609.  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
  610.  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
  611.  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
  612.  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
  613.  
  614. :YesNoWait
  615.  %Get.Click% YN
  616.  If defined ValidClick[YN] (
  617.   %Buffer:@=Main%
  618.  )Else Goto :YesNoWait
  619.  %If.Btn[YN]%[1] Exit /B 1
  620.  %If.Btn[YN]%[2] Exit /B 2
  621.  
  622. =========
  623. :ColorMod <Prefixvar.Extension> [-l]
  624. :# Prefix var doubles as the name of the Alternate data stream color variables as saved to / loaded from
  625. :# values returned:
  626. :# prefixvar.ext.FG.Color prefixvar.ext.BG.Color
  627. :# prefixvar.ext_FG_Red prefix.var_FG_Blue prefix.var_FG_Green
  628. :# prefixvar.ext_BG_Red prefix.var_BG_Blue prefix.var_BG_Green
  629. :#
  630.  %Buffer:@=Alt%
  631.  If Not "%~1" == "" Set "Type=%~1"
  632.  
  633. :# load any existing saved values.
  634.  (For /F "UsebackQ Delims=" %%G in ("%~f0:%Type%")Do %%G) 2> nul
  635.  If /I "%~2"=="-l" Goto :Eof
  636.  
  637.  If "!%Type%_FG_Red!"=="" If "!%Type%_BG_Red!"=="" (
  638.   For %%Z in ("FG" "BG")Do (
  639.    If not defined %Type%.%%~Z.Color (
  640.     Cls & Echo(Defalut value for %Type%.%%~Z.Color must be defined in format rrr;ggg;bbb
  641.     Pause
  642.     Exit
  643.    )
  644.    For /F "Tokens=1,2,3 Delims=;" %%1 in ("!%Type%.%%~Z.Color!")Do (
  645.     Set "%Type%_%%~Z_Red=%%1"
  646.     Set "%Type%_%%~Z_Green=%%2"
  647.     Set "%Type%_%%~Z_Blue=%%3"
  648.  )))
  649.  
  650.  If "!%Type%_Zone!" == "" Set "%Type%_Zone=BG"
  651.  If "!%Type%_Spectrum!" == "" Set "%Type%_Spectrum=%Type%_!%Type%_Zone!_Blue"
  652.  
  653. :# definition of /d switch assigns default toggle state to last stored value; or default value if no value stored.
  654.  
  655. %= [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
  656. %= [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
  657. %= [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
  658.  
  659. %= [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
  660. %= [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
  661.  
  662. %= [CMcontrol][2] =%         %Make.btn% CMcontrol /s " ▲   " /y 6 /x 11 /fg 255 255 255 /bg 50 20 50 /bo 33 /N
  663. %= [CMcontrol][3] =%         %Make.btn% CMcontrol /s " ▼   " /y 6 /fg 255 255 255 /bg 50 20 50 /bo 33
  664. %= [CMcontrol][1] =%         %Make.btn% CMcontrol /s "     Accept       " /bg 180 160 0 /bo 32 /y 9 /x 3
  665.  
  666. :ColorModLoop
  667.  Set "%Type%.FG.Color=!%Type%_FG_Red!;!%Type%_FG_Green!;!%Type%_FG_Blue!"
  668.  Set "%Type%.BG.Color=!%Type%_BG_Red!;!%Type%_BG_Green!;!%Type%_BG_Blue!"
  669.  
  670.  <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"
  671.  
  672.  %Get.Click% CMzone CMcolor CMcontrol
  673.  If not defined Group Goto :ColorModLoop
  674.  
  675.  If not "%Group%" == "CMcontrol" %Toggle.If.Not% !ValidClick[%Group%]!
  676.  
  677.  If "%Group%"=="CMzone" (
  678.   Set "%Type%_Zone=!Clicked[%Group%]!"
  679.   If "!Clicked[%Group%]!"=="FG" (
  680.    Set "%Type%_Spectrum=!%Type%_Spectrum:BG=FG!"
  681.   )Else Set "%Type%_Spectrum=!%Type%_Spectrum:FG=BG!"
  682.  )
  683.  
  684.  If "%Group%"=="CMcolor" Set "%Type%_Spectrum=%Type%_!%Type%_Zone!_!Clicked[%Group%]!"
  685.  
  686.  For /f "Delims=" %%G in ("!%Type%_Spectrum!") Do (
  687.   %If.Btn[CMcontrol]%[1] (
  688.    If not !%%G! EQU 255 ( Set /A "%%G+=5" )Else Start /b "" %BG.exe% play "%WINDIR%\Media\Windows Error.wav"
  689.   )
  690.   %If.Btn[CMcontrol]%[2] (
  691.    If not !%%G! EQU 0 ( Set /A "%%G-=5" )Else Start /b "" %BG.exe% play "%WINDIR%\Media\Windows Error.wav"
  692.  ))
  693.  
  694. :# Update stored Color values in alternate data stream
  695.  (For /f "Delims=" %%G in ('Set %Type%')Do Echo(Set "%%G") >"%~f0:%Type%"
  696.  
  697.  %If.Btn[CMcontrol]%[3] (
  698.   %Buffer:@=Main%
  699.   Goto :Eof
  700.  )
  701.  
  702. Goto :ColorModLoop
  703.  
  704.  
  705. ==========
  706. :ShowState <GroupName>
  707.  %Buffer:@=Alt%
  708.  For %%G in (%*)Do (
  709.   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}!
  710.  )
  711.  Timeout /T 15
  712.  %Buffer:@=Main%
  713.  Cls
  714. Goto :eof
  715.  
  716. ==========================
  717. :# REQUIRED UTILITY BG.exe
  718. :# - Allows mouse click to be accepted [ blocking input ]
  719. :# - Allows .Wav files to be played
  720. :# - Refer to the documentation at the github repository for all usage options. [ link below ]
  721.  
  722. /* BG.exe V 3.9
  723.   https://github.com/carlos-montiers/consolesoft-mirror/blob/master/bg/README.md
  724.   Copyright (C) 2010-2018 Carlos Montiers Aguilera
  725.  
  726.   This software is provided 'as-is', without any express or implied
  727.   warranty.  In no event will the authors be held liable for any damages
  728.   arising from the use of this software.
  729.  
  730.   Permission is granted to anyone to use this software for any purpose,
  731.   including commercial applications, and to alter it and redistribute it
  732.   freely, subject to the following restrictions:
  733.  
  734.   1. The origin of this software must not be misrepresented; you must not
  735.      claim that you wrote the original software. If you use this software
  736.      in a product, an acknowledgment in the product documentation would be
  737.      appreciated but is not required.
  738.   2. Altered source versions must be plainly marked as such, and must not be
  739.      misrepresented as being the original software.
  740.   3. This notice may not be removed or altered from any source distribution.
  741.  
  742.   Carlos Montiers Aguilera
  743.   cmontiers@gmail.com
  744.  */
  745.  
  746. -----BEGIN CERTIFICATE-----
  747. TVqQAAMAAAAEAAAA//8AALgAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  748. AAAAAAAAAAAAAAAAgAAAAA4fug4AtAnNIbgBTM0hVGhpcyBwcm9ncmFtIGNhbm5v
  749. dCBiZSBydW4gaW4gRE9TIG1vZGUuDQ0KJAAAAAAAAABQRQAATAEEAG3tp1sAAAAA
  750. AAAAAOAADwMLAQIZABoAAAAIAAAAAgAAcCcAAAAQAAAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  767. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  768. AAAAAAAAAAAAAAAAAAAAAFWJ5YPsGKFQUUAAg8AgiUQkBA+3RQiJBCToIhgAAMnD
  769. hcAPhBoBAABVieVXVlOJx4PsPA+3GGaF2w+E/AAAADH2x0XQAAAAADHJ6ziNdCYA
  770. Mclmg/tcD5TBdBqhUFFAAIkcJIlN1IPAIIlEJATozhcAAItN1IPHAg+3H2aF2w+E
  771. jAAAAIXJdMgPt8PHRCQEgAAAAIkEJIlF1OiaFwAAhcAPhKoAAACDfdABD45wAQAA
  772. g/5/iXXkD7fGD4+RAQAAixVQUUAAiQQkg8cCMfaNSiCJTCQE6GcXAAChUFFAAIPA
  773. IIlEJASLRdSJBCToUBcAAA+3HzHJx0XQAAAAAGaF23WD6w2QkJCQkJCQkJCQkJCQ
  774. i0XQhcB0JIP+f4l13A+3xg+PygEAAIsVUFFAAIkEJIPCIIlUJAToBRcAAI1l9Fte
  775. X13zw422AAAAAI2/AAAAAItV0IXSdGmD/n+JdeAPt8YPj0oBAACLFVBRQACJBCSN
  776. SiCJTCQE6MUWAAAxyWaD+1wPlMEPhIYAAAChUFFAAIlNzDH2g8AgiUQkBItF1IkE
  777. JOiaFgAAx0XQAAAAAItNzOnA/v//jXQmAI28JwAAAABmg/tuD4R2AQAAD4awAAAA
  778. ZoP7cg+ERgEAAGaD+3QPhXwBAAChUFFAAMcEJAkAAACDwCCJRCQE6EQWAAAxyely
  779. /v//jbYAAAAAjbwnAAAAADH2x0XQAAAAAOlX/v//ZpCDRdABweYEZoP7OQ+GrwAA
  780. AIPLIA+3w4PoVwHGuQEAAADpL/7//412AI28JwAAAACNRdzHRCQIAQAAAIlEJASN
  781. ReSJBCT/FXxRQAAPt0Xcg+wM6Uj+//+J9o28JwAAAABmg/tiD4XWAAAAoVBRQADH
  782. BCQIAAAAg8AgiUQkBOieFQAAMcnpzP3//420JgAAAACNRdzHRCQIAQAAAIlEJASN
  783. ReCJBCT/FXxRQAAPt0Xcg+wM6Y/+//+J9o28JwAAAACLRdSD6DDpT////5CNdCYA
  784. jUXax0QkCAEAAACJRCQEjUXciQQk/xV8UUAAD7dF2oPsDOkP/v//ifaNvCcAAAAA
  785. oVBRQADHBCQNAAAAg8AgiUQkBOgIFQAAMcnpNv3//5ChUFFAAMcEJAoAAACDwCCJ
  786. RCQE6OgUAAAxyekW/f//kKFQUUAAg8AgiUQkBItF1IkEJOjJFAAAMcnp9/z//2aQ
  787. oUhAQACD+AJ+OlWJ5VdWU4PsHIsVREBAAIP4A4tyCHUvx0QkCBIAAgDHRCQEAAAA
  788. AIk0JP8VhFFAAIPsDI1l9FteX13zw412AI28JwAAAADHRCQICgAAAMdEJAQAAAAA
  789. i0IMiQQk6DUUAACFwH7Oiz2EUUAAjVj/kI20JgAAAACD6wHHRCQIEgACAMdEJAQA
  790. AAAAiTQk/9eD7AyD+/914OubjbQmAAAAAI28JwAAAABVuAQAAAC6BgAAALkGAAAA
  791. ieVXVlO+CAAAALsIAAAAvwgAAACB7LwAAABmiYVs////uBAAAABmiYV4////uAgA
  792. AACDPUhAQAADZomFev///7gFAAAAZomVbv///2aJhXz///+4DAAAAGaJjXD///9m
  793. iYV+////uAcAAABmiZ1y////ZolFgLgMAAAAZom1dP///2aJRYK4EAAAAGaJvXb/
  794. //9miUWOuAoAAAC6CAAAALkMAAAAuxAAAAC+DAAAAL8MAAAAZolFkLgSAAAAZolV
  795. hGaJTYZmiV2IZol1imaJfYxmiUWSdAmNZfRbXl9dw5ChREBAAMdEJAgKAAAAx0Qk
  796. BAAAAACLQAiJBCTo4BIAAIP4CYnDd9DHRCQYAAAAAMdEJBQAAAAAx0QkEAMAAADH
  797. RCQMAAAAAMdEJAgDAAAAx0QkBAAAAMDHBCQAMEAA/xX8UEAAg+wcicbHBCQQMEAA
  798. /xUcUUAAg+wEhcCJxw+ElgAAAMdEJAQqMEAAiQQk/xUYUUAAg+wIhcCJhWT///90
  799. bA+3hJ1s////jU2Ux0QkBEIwQADHRZRUAAAAiV2YiY1g////x0WgMAAAAMdFpJAB
  800. AABmiUWcD7eEnW7///9miUWejUWoiQQk6BsSAACLjWD////HRCQEAAAAAIk0JIuV
  801. ZP///4lMJAj/0oPsDIk8JP8VBFFAAIPsBIlcJASJNCToWxIAAIPsCIk0JP8V+FBA
  802. AIPsBOm+/v//jbQmAAAAAFWJ5VZTjXXwg+wwx0QkGAAAAADHRCQUAAAAAMdEJBAD
  803. AAAAx0QkDAAAAADHRCQIAwAAAMdEJAQAAADAxwQkADBAAP8V/FBAAIPsHInDiXQk
  804. BIkEJP8VCFFAAIPsCIM9SEBAAAN0OsdF9AEAAADHRfAZAAAAiXQkBIkcJP8VJFFA
  805. AIPsCIkcJP8V+FBAAIPsBI1l+FteXcOJ9o28JwAAAAChREBAAMdEJAgKAAAAx0Qk
  806. BAAAAACLQAiJBCToABEAAIP4GXQlfxmFwHQlg/gBdaTHRfQBAAAA65uNtCYAAAAA
  807. g/gydAWD+GR1iolF8OvhkMdF9AAAAADpeP///410JgCDPUhAQAADdAfDjbYAAAAA
  808. VYnlg+wYoURAQADHRCQICgAAAMdEJAQAAAAAi0AIiQQk6IoQAACFwH4MiQQk/xU4
  809. UUAAg+wEycOQjbQmAAAAAFWJ5YPsSI1F6IkEJP8VFFFAAA+3RfaD7ATHBCRUMEAA
  810. iUQkIA+3RfSJRCQcD7dF8olEJBgPt0XwiUQkFA+3Re6JRCQQD7dF6olEJAwPt0Xo
  811. iUQkCA+3ReyJRCQE6AcQAADJw422AAAAAI28JwAAAABVieVXVlONfcyNddSD7FzH
  812. RCQYAAAAAMdEJBQAAAAAx0QkEAMAAADHRCQMAAAAAMdEJAgDAAAAx0QkBAAAAMDH
  813. BCSGMEAA/xX8UEAAicONRdCD7ByJHCSJRCQE/xUMUUAAi0XQg+wIiRwkJC4MkIlE
  814. JAShMFFAAIlFxP/Qg+wIkIl8JAzHRCQIAQAAAIl0JASJHCT/FSBRQACD7BBmg33U
  815. AnXdg33cAXXXD7912g+/fdjHBCSUMEAAiXQkBIl8JAjB5hDoMA8AAItF0IkcJAH+
  816. iUQkBP9VxIPsCIkcJP8V+FBAAIPsBIk0JP8VAFFAAJBVieVTg+wEix1MUUAA/9OF
  817. wHQdPeAAAAB0FqNAQEAAg8QEW13DjXQmAI28JwAAAAD/0wUAAQAAo0BAQACDxARb
  818. XcONtCYAAAAAjbwnAAAAAFWJ5VOD7AT/FVRRQACFwHUfxwVAQEAAAAAAAIPEBFtd
  819. w+sNkJCQkJCQkJCQkJCQkIsdTFFAAP/ThcB0FD3gAAAAdA2jQEBAAIPEBFtdw2aQ
  820. /9MFAAEAAOvqjbQmAAAAAIM9SEBAAAR0B8ONtgAAAABVieVXVlOD7FzHRCQYAAAA
  821. AMdEJBQAAAAAx0QkEAMAAADHRCQMAAAAAMdEJAgDAAAAx0QkBAAAAMDHBCQAMEAA
  822. /xX8UEAAicaNRdKD7ByJNCSJRCQE/xUQUUAAoURAQACD7AgPt33gx0QkCAoAAADH
  823. RCQEAAAAAA+3XeJmK33ci0AIZitd3okEJOjCDQAAiUXEoURAQADHRCQICgAAAMdE
  824. JAQAAAAAi0AMiQQk6J8NAACLVcQxyWaFwA9IwYk0JGaF0g9I0WY5xw9P+GY50w9P
  825. 2g+3/8HjEAn7iVwkBP8VKFFAAIPsCIk0JP8V+FBAAIPsBI1l9FteX13DjbYAAAAA
  826. VYnlU4PsJMdEJBgAAAAAx0QkFAAAAADHRCQQAwAAAMdEJAwAAAAAx0QkCAMAAADH
  827. RCQEAAAAwMcEJAAwQAD/FfxQQACD7ByDPUhAQAADicO4BwAAAHQpiRwkiUQkBP8V
  828. NFFAAIPsCIkcJP8V+FBAAItd/IPsBMnDkI20JgAAAAChREBAAMdEJAgQAAAAx0Qk
  829. BAAAAACLQAiJBCTosAwAAA+3wOuyjXQmAI28JwAAAAChSEBAAIP4BX8G88ONdCYA
  830. VYPoAYnlV1ZTg+x8iUWkx0QkGAAAAADHRCQUAAAAAMdEJBADAAAAx0QkDAAAAADH
  831. RCQIAwAAAMdEJAQAAADAxwQkADBAAP8V/FBAAInDjUXSg+wciRwkiUQkBP8VEFFA
  832. AKFEQEAAg+wIx0QkCAoAAADHRCQEAAAAAItACIkEJOgMDAAAicahREBAAMdEJAgK
  833. AAAAx0QkBAAAAACLQAyJBCTo6gsAAGajIEBAAGajPEBAAA+3ReCJHSxAQABmK0Xc
  834. Zok1IkBAAMdFqBQAAADHRawEAAAAZqMwQEAAD7dF4mYrRd5mozJAQAC4AQAAAGaj
  835. NEBAALgBAAAAZqM2QEAAMcBmozhAQAAxwGajOkBAAKE8UUAAiUWgifaNvCcAAAAA
  836. i32soURAQADHRCQIEAAAAMdEJAQAAAAAiwS4iQQk6E0LAACJ+WajKkBAAKFEQEAA
  837. g8ECiU2si02oizQIhfYPhEkBAAAPtx5mhdsPhD0BAAAx/8dFtAAAAAAx0utSjXYA
  838. MdJmg/tcD5TCdDVmhdsPhAwCAABmg/sKD4XCAQAAD7cFPEBAAGaDBSJAQAABZqMg
  839. QEAAjbYAAAAAjbwnAAAAAIPGAg+3HmaF2w+EoQAAAIXSdK0Pt9PHRCQEgAAAAIkU
  840. JIlVsOi/CgAAhcAPhN8AAACDfbQBi1WwD44iAgAAg/9/iX3MifoPj0QDAABmhdIP
  841. hLsCAABmg/oKD4UxAgAAD7cFPEBAAGaDBSJAQAABZoP7CmajIEBAAA+FrAIAAA+3
  842. BTxAQABmgwUiQEAAAYPGAjH/MdLHRbQAAAAAZqMgQEAAD7ceZoXbD4Vi////jXYA
  843. i0W0hcB0NoP/f4l9xIn4D4+rBQAAZoXAD4RiBQAAZoP4Cg+FuAQAAA+3BTxAQABm
  844. gwUiQEAAAWajIEBAAINFqAiLTaw5TaQPj2P+//+NZfRbXl9dw410JgCNvCcAAAAA
  845. i0W0hcAPhNUAAACD/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QADHRCQQIEBA
  861. AMdEJAQoQEAAiUQkDKE0QEAAiUQkCKEsQEAAiQQk/xU8UUAAg+wUifaNvCcAAAAA
  862. D7cFIEBAAIPAAWajIEBAAOn8/P//jXQmAI28JwAAAABmhcB4e2Y5BTBAQAB8cg+3
  863. DSJAQABmhcl4ZmY7DTJAQAB/XYPAAYPBAYlVtGajJEBAAKE4QEAAZokdKEBAAGaJ
  864. DSZAQADHRCQQIEBAAMdEJAQoQEAAiUQkDKE0QEAAiUQkCKEsQEAAiQQk/xU8UUAA
  865. D7cFIEBAAItVtIPsFI12AIPAATH/x0W0AAAAAGajIEBAAOkJ+///ifaNvCcAAAAA
  866. ZoP7Yg+FNgIAAA+3BSBAQABmhcAPiDb9//9mOwUwQEAAD48p/f//D7cVIkBAAGaF
  867. 0g+IGf3//2Y7FTJAQAAPjwz9//+5CAAAAGaJDShAQADp/wIAAI10JgCNvCcAAAAA
  868. jUXCx0QkCAEAAACJRCQEjUXIiQQk/xV8UUAAD7dVwoPsDOmi+///ifaNvCcAAAAA
  869. D7cVIEBAAGaF0nh0ZjsVMEBAAH9rD7cNIkBAAGaFyXhfZjsNMkBAAH9WZqMoQEAA
  870. oThAQACDwgGDwQFmiRUkQEAAx0QkECBAQABmiQ0mQEAAx0QkBChAQACJRCQMoTRA
  871. QACJRCQIoSxAQACJBCT/FTxRQAAPtxUgQEAAg+wUZpCDwgGDRagIi02sOU2kZokV
  872. IEBAAA+PNvn//+nO+v//kGaDBSBAQAABg0WoCItNrDlNpA+PGPn//+mw+v//jXYA
  873. D7cFPEBAAGaDBSJAQAABMdJmoyBAQADplPn//410JgCNRcLHRCQIAQAAAIlEJASN
  874. RcSJBCT/FXxRQAAPt0XCg+wM6S76//+J9o28JwAAAAAPtwUgQEAAZoXAD4ig+///
  875. ZjsFMEBAAA+Pk/v//w+3FSJAQABmhdIPiIP7//9mOxUyQEAAD492+///g8ABg8IB
  876. uw0AAABmoyRAQAChOEBAAGaJHShAQABmiRUmQEAAx0QkECBAQADHRCQEKEBAAIlE
  877. JAyhNEBAAIlEJAihLEBAAIkEJP9VoA+3BSBAQACD7BTpG/v//410JgCNvCcAAAAA
  878. ZoP7Cg+EBv///w+3BSBAQABmhcAPiPb6//9mOwUwQEAAD4/p+v//D7cVIkBAAGaF
  879. 0g+I2fr//2Y7FTJAQAAPj8z6//9miR0oQEAA6cQAAACDwAGDwQGJVbBmoyRAQACh
  880. OEBAAGaJHShAQABmiQ0mQEAAx0QkECBAQADHRCQEKEBAAIlEJAyhNEBAAIlEJAih
  881. LEBAAIkEJP8VPFFAAA+3BSBAQACD7BSLVbDp4fn//4PAAYPCAWaJHShAQABmoyRA
  882. QAChOEBAAGaJFSZAQADHRCQQIEBAAMdEJAQoQEAAiUQkDKE0QEAAiUQkCKEsQEAA
  883. iQQk/xU8UUAAD7cFIEBAAIPsFOkY+///uQkAAABmiQ0oQEAAg8ABg8IBx0QkECBA
  884. QABmoyRAQAChOEBAAGaJFSZAQADHRCQEKEBAAIlEJAyhNEBAAIlEJAihLEBAAIkE
  885. JP8VPFFAAA+3BSBAQACD7BTpqvn//412AI28JwAAAABVieVXVlOD7FzHRCQEojBA
  886. AMcEJAAAAADoEwIAAKFQUUAAg8AgiQQk/xVIUUAAx0QkBAAAAgCJBCT/FVhRQACh
  887. SEBAAIP4Aw+EAwEAAH8RjWX0W15fXcOJ9o28JwAAAACD6AHHRCQYAAAAAMdEJBQA
  888. AAAAiUXAx0QkEAMAAAC7DAAAAMdEJAwAAAAAx0QkCAMAAAC/AgAAAMdEJAQAAADA
  889. xwQkADBAAP8V/FBAAInCiUXEjUXSg+wciUQkBIkUJP8VEFFAAIPsCJCNtCYAAAAA
  890. oURAQADHRCQIEAAAAMdEJAQAAAAAiwS4g8cCiQQk6C0BAACLDURAQAAPt8CLNBmJ
  891. RCQEg8MIi0XEiQQk/xU0UUAAifCD7AjoBOn//zl9wH+vD7dF2ot1xIk0JIlEJAT/
  892. FTRRQACD7AiJNCT/FfhQQACD7ASNZfRb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cmVudENvbnNvbGVGb250RXgAVABlAHIAbQBpAG4AYQBsAAAAJQBkACAAJQBkACAA
  909. JQBkACAAJQBkACAAJQBkACAAJQBkACAAJQBkACAAJQBkAAoAAABDAE8ATgBJAE4A
  910. JAAAACUAZAAgACUAZAAKAAAAAABQAFIASQBOAFQAAABGAEMAUABSAEkATgBUAAAA
  911. QwBPAEwATwBSAAAATABPAEMAQQBUAEUAAABMAEEAUwBUAEsAQgBEAAAASwBCAEQA
  912. AABNAE8AVQBTAEUAAABEAEEAVABFAFQASQBNAEUAAABTAEwARQBFAFAAAABDAFUA
  913. UgBTAE8AUgAAAEYATwBOAFQAAABQAEwAQQBZAAAAAACkMEAAACZAALAwQACAG0AA
  914. wDBAANAaQADMMEAAwBlAANowQABgGUAA6jBAABAZQADyMEAAIBhAAP4wQACwF0AA
  915. EDFAAGAXQAAcMUAAYBZAACoxQAAwFEAANDFAAIATQABHQ0M6ICh0ZG02NC0xKSA1
  916. LjEuMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  917. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABkUAAAAAAAAAAAAADcUwAA
  918. +FAAALBQAAAAAAAAAAAAACBUAABEUQAA6FAAAAAAAAAAAAAAMFQAAHxRAADwUAAA
  919. AAAAAAAAAABAVAAAhFEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAjFEAAJpRAACoUQAA
  920. tlEAAMRRAADcUQAA7lEAAAxSAAAcUgAALlIAAD5SAABSUgAAalIAAIZSAACYUgAA
  921. qlIAAMRSAADMUgAAAAAAAOJSAAD0UgAA/lIAAAhTAAAQUwAAGlMAACZTAAAyUwAA
  922. PFMAAEhTAABUUwAAXlMAAGhTAAAAAAAAclMAAAAAAACEUwAAAAAAAIxRAACaUQAA
  923. qFEAALZRAADEUQAA3FEAAO5RAAAMUgAAHFIAAC5SAAA+UgAAUlIAAGpSAACGUgAA
  924. mFIAAKp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GxsAAAoUAAA
  940. VVNFUjMyLmRsbAAAPFAAAFdJTk1NLkRMTAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  941. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  942. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  943. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  944. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  945. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  946. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  947. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  948. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  949. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
  950. -----END CERTIFICATE-----
  951.  
  952. ==============================
  953. :ButtonsMain Script body - USAGE DEMO
  954. ==============================
  955.  
  956. :# Enable Macros; facilitate nested variables !element[%index%]!
  957.  Setlocal enableDelayedExpansion
  958.  
  959. :# Ensure no Existing variables prefixed 'Btn'
  960.  For /f "Tokens=1,2 Delims==" %%G in ('Set Btn 2^> nul')Do Set "%%G="
  961.  
  962.  Set /A "Density=4", "minX=5", "maxX=45", "minY=5", "maxY=20"
  963.  Set "Live.Cell.Char=╬"
  964.  Set "Live.Cell.Char[i]=20"
  965.  
  966.  For %%z in (Live Dead)Do Call :ColorMod %%z.cell -l
  967.  
  968.  If "!Live.Cell.FG.Color!"=="" Set "Live.Cell.FG.Color=250;70;0"
  969.  If "!Live.Cell.BG.Color!"=="" Set "Live.Cell.BG.Color=0;80;160"
  970.  If "!Dead.Cell.FG.Color!"=="" Set "Dead.Cell.FG.Color=20;30;40"
  971.  If "!Dead.Cell.BG.Color!"=="" Set "Dead.Cell.BG.Color=0;0;0"
  972.  
  973. %= [demo][1] =% %Make.Btn% demo /S Option One /t
  974. %= [demo][2] =% %Make.Btn% demo /S Option Two /t
  975. %= [demo][3] =% %Make.Btn% demo /S Option Three /t
  976. %= [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
  977.  
  978. :Demoloop REM [ demo -  Generic menu via a loop ]
  979. REM redefines buttons each loop with current color values. Note /N switch used to reset
  980. REM button group.
  981. %= [CellCol][1] =% %Make.Btn% CellCol /S Live.Cell /X 20/fg %!!% /bg %!!% /bo 33 /N
  982. %= [CellCol][2] =% %Make.Btn% CellCol /S Dead.Cell /fg %!!% /bg %!!% /bo 33
  983.  
  984. REM Expand Get.Click macro with arguments corresponding to the group names of buttons defined using make.btn
  985. REM Each loop Displays Buttons current toggle state. Use goto to break out of a loop to your target label.
  986.  %Get.Click% demo CellCol
  987.  
  988.  Title Y;X:!C{pos}! C:!Clicked[%Group%]! VC:!ValidClick[%Group%]!
  989.  %If.btn[demo]%[4] (
  990.   Call :YesNo Yes No "Are you sure?"
  991.   If "!Clicked[YN]!" == "Yes" (
  992.    cls
  993.   REM [ demo - Familiarise users with state definitions for toggle buttons. ]
  994.    Set btn[ | findstr /lic:"{state}"
  995.    Pause
  996.    %Clean.Exit%
  997.   )
  998.  )
  999.  
  1000. Rem assess If button clicked belonged to a specific group, if true Passes the buttons text to the Function ColorMod
  1001.  If "%Group%"=="CellCol" Call :ColorMod !Clicked[CellCol]!
  1002.  
  1003. Goto :Demoloop
Add Comment
Please, Sign In to add comment