New batch tool: Cursortemplate.bat
Posted: 16 Jun 2017 06:41
This is a tool that I have been working on for a while. The tool is a batch file, so use the call command for it.
The tool requires batbox.exe and (if you use the button command) button.bat in the same folder. For help, use the /? command.
This tool creates a simple cursor, which is controlled through certain buttons defined in a generated config file.
You may use, share, and modify this tool, as long as you give credit where it is due.
If you find any bugs, or would like for different functions, please leave a comment in this forum.
For a list of bugs you can read the document. The document has 2 formats: .docx and .txt.The document is good if you need help or would like to learn more.
Download link (with batbox.exe and button.bat included): https://www.dropbox.com/s/ytniuaf5sgd1bya/Cursortemplate.zip?dl=0
Documents https://www.dropbox.com/s/acc8dnl4wjykuo3/Documents.zip?dl=0
Code for Customtemplate.bat (you have to download batbox.exe and button.bat seperatly):
The tool requires batbox.exe and (if you use the button command) button.bat in the same folder. For help, use the /? command.
This tool creates a simple cursor, which is controlled through certain buttons defined in a generated config file.
You may use, share, and modify this tool, as long as you give credit where it is due.
If you find any bugs, or would like for different functions, please leave a comment in this forum.
For a list of bugs you can read the document. The document has 2 formats: .docx and .txt.The document is good if you need help or would like to learn more.
Download link (with batbox.exe and button.bat included): https://www.dropbox.com/s/ytniuaf5sgd1bya/Cursortemplate.zip?dl=0
Documents https://www.dropbox.com/s/acc8dnl4wjykuo3/Documents.zip?dl=0
Code for Customtemplate.bat (you have to download batbox.exe and button.bat seperatly):
Code: Select all
@echo off
:: This tool was made by TheHunterManx.
:: To find out how to use, use /?
if "%1" EQU "/?" goto help
if "%1" EQU "/command" if "%2" EQU "/?" goto help2
if "%1" EQU "Button" if "%2" EQU "/?" goto help3
if "%1" EQU "/w" call :Config Write&exit /b 0
if "%1" EQU "/r" call :Config Read&exit /b 0
if "%1" EQU "/c" call :controls&exit /b 0
if "%3" NEQ "" set Tempc=%3
if "%3" EQU "" set Tempc=N
setlocal enableextensions enabledelayedexpansion
set timer=0
:begin
set Light=0
set Last3=None
set Cursor=/d ">"
if %timer% EQU %Time% set timer=1&goto begin2
set /a timer=%timer%+1
if "%1" EQU "Button" call Button.bat "!PInput%timer%!" 80 PButton%timer% N 3 "!PInput%timer%!" 70 PButton%timer%2 N 3
if "%1" EQU "" set PButton%timer%=/c 0x08 /d "!PInput%timer%!"&set PButton%timer%2=/c 0x07 /d "!PInput%timer%!"
if "%1" EQU "-" set PButton%timer%=/c 0x08 /d "!PInput%timer%!"&set PButton%timer%2=/c 0x07 /d "!PInput%timer%!"
if "%2" NEQ "" set PButton%timer%=/c 0x%2 /d "!PInput%timer%!"&set PButton%timer%2=/c 0x%2 /d "!PInput%timer%!"
for /F "tokens=1,2 delims=." %%A in ("!Input%timer%!") do (
set Temp1=%%A
set Temp2=%%B)
if "%1" EQU "Button" batbox.exe /o %Temp1% %Temp2% !PButton%timer%!
if "%1" EQU "" batbox.exe /g %Temp1% %Temp2% !PButton%timer%!
if "%1" EQU "-" batbox.exe /g %Temp1% %Temp2% !PButton%timer%!
goto begin
:begin2
if "%2" NEQ "" set Cursor=/c 0x%2 %Cursor%
if not exist Cursor1cfg.bat call :Config New
call :Config Read
if "%1" EQU "" (set Temp=None
) else set Temp=%1
if "%1" EQU "-" set Temp=None
call :mainmenu %Temp%
if "%Temp%" EQU "exit" goto exitspecial
goto begin2
:exitspecial
endlocal & set Action=%Action%& set Output1=%TInput0%& set Output2=%TInput1%
exit /b 0
:mainmenu
REM cursor ([currentx.currenty]) ([boundriesxbegin.boundriesxend]:[boundriesbeginy.boundriesendy]) (x change) (y change) (script)
REM
set PTemp=None
for /F "tokens=1-4 delims=." %%A in ("%Input1%.!Input%Time%!") do (
set Temp1=%%A
set Temp2=%%B
set Temp3=%%C
set Temp4=%%D)
set /a Temp=%Temp4%-%Temp2%
if "%Timey%" NEQ "" (
set /a Temp0=%Timey%-1
set Timey=
) else set /a Temp0=%Time%-1
if %Temp% GEQ %Temp0% (set /a Temp6=%Temp%/%Temp0%) else set Temp6=0
set /a Temp=%Temp3%-%Temp1%
if "%Timex%" NEQ "" (
set /a Temp0=%Timex%-1
set Timex=
) else set /a Temp0=%Time%-1
if %Temp% GEQ %Time% (set /a Temp5=%Temp%/%Temp0%) else set Temp5=0
set /a Temp=%Temp1%-1
set Last3=None
set Last2=0
if "%Tempc%" EQU "N" call :cursor %Temp%.%Temp2% %Temp1%.%Temp2%:%Temp3%.%Temp4% %Temp5% %Temp6% Lightup %1&goto :EOF
if "%Tempc%" NEQ "N" call :cursor %Tempc% %Temp1%.%Temp2%:%Temp3%.%Temp4% %Temp5% %Temp6% Lightup %1&goto :EOF
goto :EOF
:cursor
if "%1" EQU "" goto :EOF
if "%2" EQU "" goto :EOF
if "%3" EQU "" set TInput4=None
if "%4" EQU "" set TInput5=None
if "%5" EQU "" (set TInput8=None) else set TInput8=%5
if "%6" NEQ "" if "%6" NEQ "None" if "%TInput9%" NEQ "None" (set TInput9=%6) else set TInput9=No
if "%PTemp%" EQU "None" for /F "tokens=1,2 delims=." %%A in ("%1") do (
set TInput0=%%A
set TInput1=%%B)
REM TInput0=x TInput1=y
if "%PTemp%" EQU "None" for /F "tokens=1-4 delims=.:" %%A in ("%2") do (
set TInput2=%%A
set TInput3=%%C
set TInput6=%%B
set TInput7=%%D)
REM TInput2=beginx TInput3=endx TInput6=beginy TInput7=endy
set PTemp=No
if "%3" NEQ "" set TInput4=%3
if "%4" NEQ "" set TInput5=%4
REM TInput4=changex TInput5=changey
if "%TInput9%" EQU "Button" (
set /a TInput1=%TInput1%+1
set /a TInput6=%TInput6%+1
set /a TInput7=%TInput7%+1
set /a TInput2=%TInput2%-1
set /a TInput3=%TInput3%-1)
if "%TInput9%" EQU "" (
set /a TInput2=%TInput2%-1
set /a TInput3=%TInput3%-1)
if "%TInput9%" EQU "" set TInput9=None
if "%TInput9%" EQU "No" set TInput9=None
if "%TInput8%" NEQ "None" call :%TInput8%
set TInput9=None
set Last1=%TInput0%
set Last2=%TInput1%
set Last3=Yes
call :echocursor %TInput0% %TInput1%
call :controls
call :echocursor %TInput0% %TInput1% Blank
set Temp=1
if "%Action%" EQU "Up" set /a TInput1=%TInput1%-%TInput5%
if "%Action%" EQU "Down" set /a TInput1=%TInput1%+%TInput5%
if "%Action%" EQU "Left" set /a TInput0=%TInput0%-%TInput4%
if "%Action%" EQU "Right" set /a TInput0=%TInput0%+%TInput4%
if "%Action%" EQU "Action1" set Temp=exit&goto :EOF
if "%Action%" EQU "Action2" set Temp=exit&goto :EOF
if "%Action%" EQU "Action3" set Temp=exit&goto :EOF
if %TInput0% LSS %TInput2% set TInput0=%TInput2%
if %TInput0% GTR %TInput3% set TInput0=%TInput3%
if %TInput1% LSS %TInput6% set TInput1=%TInput6%
if %TInput1% GTR %TInput7% set TInput1=%TInput7%
goto cursor
:echocursor
if "%3" EQU "" (
batbox /g %1 %2 %Cursor% /g %1 %2
goto :EOF)
batbox /g %1 %2 /d " " /g %1 %2
goto :EOF
:Lightup
set timer=0
set timer2=0
if %Light% EQU 1 if "%TInput9%" EQU "None" call :Lightup2
if "%TInput9%" EQU "Button" set Light=1&set TInput9=None&call :Lightup2
if "%TInput9%" EQU "None" if %Light% NEQ 1 call :Lightup3
goto :EOF
:Lightup2
set Light=1
set /a timer=%timer%+1
for /F "tokens=1,2 delims=." %%A in ("!Input%timer%!") do (
set /a Temp1=%%A
set /a Temp2=%%B
)
if "%Last3%" EQU "None" set Last1=0
set /a Temp9=%Temp2%+1
set /a Temp3=%Temp1%-1
set /a Temp5=%Last1%+1
set /a Temp6=%Last2%-1
set /a Temp7=%Last2%-2
set /a Temp8=%Temp2%-1
if %TInput0% EQU %Temp3% if %TInput1% EQU %Temp9% (
if "%Last3%" EQU "Yes" (
set timer3=1
call :checkinput %Temp5%.%Temp6%
batbox /o %Temp5% %Temp6% !Temp!
)
batbox /o %Temp1% %Temp2% !PButton%timer%2!
goto :EOF)
if %timer% EQU %Time% goto :EOF
goto Lightup2
:Lightup3
set /a timer=%timer%+1
for /F "tokens=1,2 delims=." %%A in ("!Input%timer%!") do (
set /a Temp1=%%A
set /a Temp2=%%B
)
if "%Last3%" EQU "None" set Last1=0
set /a Temp9=%Temp2%
set /a Temp3=%Temp1%-1
set /a Temp5=%Last1%+1
set /a Temp6=%Last2%
set /a Temp7=%Last2%-1
set /a Temp8=%Temp2%-1
if %TInput0% EQU %Temp3% if %TInput1% EQU %Temp9% (
if "%Last3%" EQU "Yes" (
set timer3=1
call :checkinput %Temp5%.%Temp6%
batbox /g %Temp5% %Temp6% !Temp!
)
batbox /g %Temp1% %Temp2% !PButton%timer%2!
goto :EOF)
if %timer% EQU %Time% goto :EOF
goto Lightup3
:checkinput
for /l %%A in (1 1 %Time%) do (
if "%1" EQU "!Input%%A!" set Temp=!PButton%%A!&goto :EOF
)
if %timer3% EQU %Time% goto :EOF
set /a timer3=!timer3!+1
goto checkinput
:controls
batbox /k_
set TInput=%errorlevel%
call :Checker
if "%Action%" EQU "None" goto controls
goto :EOF
:touch
for /F "tokens=1,2 delims=:," %%A in ('Batbox /m') do (
set x=%%A
set y=%%B
)
goto :EOF
:Config
if "%1" EQU "Read" if not exist Cursor1cfg.bat call :Config New&call Cursor1cfg.bat&goto :EOF
if "%1" EQU "Read" if exist Cursor1cfg.bat call Cursor1cfg.bat&goto :EOF
if "%1" EQU "New" (
echo set PUp=327
echo set P2Up=119
echo set PDown=335
echo set P2Down=115
echo set PLeft=330
echo set P2Left=97
echo set PRight=332
echo set P2Right=100
echo set PAction=101
echo set P2Action=13
echo set PAction2=120
echo set P2Action2=111
echo set PAction3=122
echo set P2Action3=112
echo set Soundlevel=20)>Cursor1cfg.bat
if "%1" EQU "Write" (
echo set PUp=%PUp%
echo set P2Up=%P2Up%
echo set PDown=%PDown%
echo set P2Down=%P2Down%
echo set PLeft=%PLeft%
echo set P2Left=%P2Left%
echo set PRight=%PRight%
echo set P2Right=%P2Right%
echo set PAction=%PAction%
echo set P2Action=%P2Action%
echo set PAction2=%PAction2%
echo set P2Action2=%P2Action2%
echo set PAction3=%PAction3%
echo set P2Action3=%P2Action3%
echo set Soundlevel=%Soundlevel%)>Cursor1cfg.bat
goto :EOF
:help
echo This batch file was made for making useful batch files easier. This file should also support XP+.
echo If it doesn't support it, or there is a bug, please contact me on the forums. I may not fix it
echo right away, but I will try to eventually.
echo Use /command /? for commands.
echo This file creates a cursor, which uses variables:
echo Time (the ammount of variables it uses),
echo Input1-Input(the ammount Time has) (The x and y coordinates for PInput),
echo PInput1-PInput(the ammount Time has) (The words displayed at x and y),
echo Output1 (the x coordinates the cursor is at when you press any action key),
echo Output2 (the y coordinates the cursor is at when you press any action key),
echo Action (the action you used (action1,action2,action3)),
echo Timex (optional) (the ammount of times the x coordinate is different in Input) and
echo Timey (optional) (the ammount of times that the y coordinate is different in Input).
echo.
echo Always use the same pattern for x and y (for example 1 2 3, 15 30 45 or 10 30 50)
echo or else it will look funny.
echo The file normally only supports one direction (x or y) normally, however,
echo if you also define Timex and Timey, it has limited support for both directions.
echo There is also limited support for color, simply use - or the Button command, and then the color
echo in hex format, with the 1st digit being the text color, and the 2nd digit being the background color.
exit /b 0
:help2
echo The "/?" command does not require batbox.bat.
echo The "/w" and "/r" command does not require batbox.bat.
echo The "/c" command requires batbox.bat.
echo The "Button" command requires batbox.bat and button.bat.
echo Button.bat was created by KVC, and batbox.bat was found on dos9.com.
echo.
echo The /? command types the help menu, as seen here.
echo The /w command writes a configuration to the config file.
echo The /r command reads the config file.
echo The /c command sets the Action variable to whatever button the user presses that is defined in the config file.
echo For more info on Button, use "Button /?"
exit /b 0
:help3
echo The Button command uses Button.bat to function. You could call this an extension command.
echo To use, type for the command "Button", without the quotes. This command also has limited color support.
echo The colors use hex, with the 1st digit being the text color, and the 2nd digit being the background color.
echo Button.bat was created by KVC.
exit /b 0
:Checker
if %TInput% EQU %PUp% (set Action=Up&goto :EOF) else if %TInput% EQU %P2Up% (set Action=Up)&goto :EOF
if %TInput% EQU %PDown% (set Action=Down&goto :EOF) else if %TInput% EQU %P2Down% (set Action=Down)&goto :EOF
if %TInput% EQU %PLeft% (set Action=Left&goto :EOF) else if %TInput% EQU %P2Left% (set Action=Left)&goto :EOF
if %TInput% EQU %PRight% (set Action=Right&goto :EOF) else if %TInput% EQU %P2Right% (set Action=Right)&goto :EOF
if %TInput% EQU %PAction% (set Action=Action1&goto :EOF) else if %TInput% EQU %P2Action% (set Action=Action1)&goto :EOF
if %TInput% EQU %PAction2% (set Action=Action2&goto :EOF) else if %TInput% EQU %P2Action2% (set Action=Action2)&goto :EOF
if %TInput% EQU %PAction3% (set Action=Action3&goto :EOF) else if %TInput% EQU %P2Action3% (set Action=Action3)&goto :EOF
set Action=None
goto :EOF