New batch tool: Cursortemplate.bat

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
TheHunterManX
Posts: 54
Joined: 14 Aug 2015 05:59

New batch tool: Cursortemplate.bat

#1 Post by TheHunterManX » 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):

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
Last edited by TheHunterManX on 17 Jun 2017 10:04, edited 2 times in total.

Compo
Posts: 600
Joined: 21 Mar 2014 08:50

Re: New batch tool: Cursortemplate.bat

#2 Post by Compo » 16 Jun 2017 08:29

TheHunterManX wrote:

Code: Select all

echo This batch file was made for making useful batch files easier.

I have accumulated quite a number of batch files over the years and every single one of them is useful. Could you therefore please tell me what this does and how it is supposed to make the running of those scripts easier. (It isn't explained in the post or in the script's own help file).

Note: If any of your response makes mention of games or the viewing of images don't bother replying, (you will have already failed to satisfy the 'useful' criteria from the get go).

TheHunterManX
Posts: 54
Joined: 14 Aug 2015 05:59

Re: New batch tool: Cursortemplate.bat

#3 Post by TheHunterManX » 16 Jun 2017 08:56

Compo wrote:I have accumulated quite a number of batch files over the years and every single one of them is useful. Could you therefore please tell me what this does and how it is supposed to make the running of those scripts easier. (It isn't explained in the post or in the script's own help file).

Note: If any of your response makes mention of games or the viewing of images don't bother replying, (you will have already failed to satisfy the 'useful' criteria from the get go).

Well, lets see...
I guess I wrote that wrong. What I mean is that "This tool makes creating a batch file that requires user selection easier.".
I also guess that "easier" depends on the type of batch file your making. Sorry for the misunderstanding.

Aacini
Expert
Posts: 1914
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: New batch tool: Cursortemplate.bat

#4 Post by Aacini » 16 Jun 2017 09:45

@TheHunterManX,

Excuse me. I read the description of the program and I don't understand what it does and certainly I want not to review the code in order to investigate that...

I know that the "cursor" is the small blinking square that mark the position of the next input character, so I don't understand what "creates a simple cursor, which is controlled through certain buttons" means. What is the purpose to "create a cursor" different than the standard one? What "buttons" refers to in this context?

IMHO you should describe in a much clearer way the purpose of your program... :(

Antonio

ShadowThief
Expert
Posts: 1166
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: New batch tool: Cursortemplate.bat

#5 Post by ShadowThief » 16 Jun 2017 16:49

Some thoughts...
  • I can't figure out how to use this
  • Maybe it's just years of reading man pages, but the help is really hard to read
  • There's a typo on line 251 where you typed ehco instead of echo
  • I think this is used for making menus, but I'm not positive
  • Literally anything even remotely resembling an example would be greatly appreciated
  • Properly indent and comment your code

TheHunterManX
Posts: 54
Joined: 14 Aug 2015 05:59

Re: New batch tool: Cursortemplate.bat

#6 Post by TheHunterManX » 17 Jun 2017 08:22

ShadowThief wrote:Some thoughts...
  • I can't figure out how to use this
  • Maybe it's just years of reading man pages, but the help is really hard to read
  • There's a typo on line 251 where you typed ehco instead of echo
  • I think this is used for making menus, but I'm not positive
  • Literally anything even remotely resembling an example would be greatly appreciated
  • Properly indent and comment your code


Here are some answers:
- To use this, put this file into the folder that you are going to run this in.
- Should I fix up what the help says so that it is easier to understand? I'll try to.
- Thanks for telling me about this! I will fix it.
- Yes, it can be used for menus, but there is more you can use it for.
- Read the bottom of this comment.
- I guess I can do that.
Thank you for telling me about this stuff. It helps me when people respond so that the program is easier to use.

Aacini wrote:@TheHunterManX,

Excuse me. I read the description of the program and I don't understand what it does and certainly I want not to review the code in order to investigate that...

I know that the "cursor" is the small blinking square that mark the position of the next input character, so I don't understand what "creates a simple cursor, which is controlled through certain buttons" means. What is the purpose to "create a cursor" different than the standard one? What "buttons" refers to in this context?

IMHO you should describe in a much clearer way the purpose of your program... :(
Antonio


So, to answer your questions....
- "a simple cursor" refers to the ">" that is used, where "create" is the display of it.
- "buttons" refer to the keyboard input. You can find the keyboard button config in Cursor1cfg.bat
- I will try to describe it clearer.

I understand that some people don't understand how it works, so I will make a example of how to use this.
Example:

Code: Select all

@echo off
:: I used setlocal because it allows for variables to be used on parse time, rather than execution time.
setlocal EnableDelayedExpansion
:: Calls preset1.
call :preset1
:: the beginning of the script.
:begin
cls
:: Goes to a certain point in the command prompt and types something.
batbox /g 2 2 /d "Do you like this example?"
:: Calls the tool.
call Cursortemplate.bat
:: The output from the tool are 3 variables, Output1(cursor's x position), Output2(cursor's y position) and Action (Action1, Action2 or Action3).
:: Sets the Output3 variable to the Output1 variable plus 1.
set /a Output3=%Output1%+1
:: sets timer to 0 for the check script
set timer=0
:: Calls :check. Returns back the variable selected (Yes, No, Maybe) into OInput.
call :check %Output3%.%Output2%
:: Compares the variable selected. Calls another label.
if "%OInput%" EQU "Yes" call :Yes
if "%OInput%" EQU "No" call :No
if "%OInput%" EQU "Maybe" call :Maybe
pause >nul
goto begin
:: preset1 contains variables that [b]have[/b] to be set before calling the tool.
:preset1
:: The ammount of Input's you have.
set Time=3
:: The x and y locations of where the PInput's go.
set Input1=2.3
set Input2=2.4
set Input3=2.5
:: Words that the cursor hovers over.
set PInput1=Yes
set PInput2=No
set PInput3=Maybe
goto :EOF
:check
set /a timer=!timer!+1
set OInput=!PInput%timer%!
if %1 EQU !Input%timer%! set timer=0&goto :EOF
if %timer% EQU %Time% set timer=0&goto :EOF
goto check
:Yes
batbox /g 2 6 /d "You like it? Thanks."
goto :EOF
:No
batbox /g 2 6 /d "You don't like it? I'm sorry for making such a crappy example..."
goto :EOF
:Maybe
batbox /g 2 6 /d "So, which one?"
goto :EOF

ShadowThief
Expert
Posts: 1166
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: New batch tool: Cursortemplate.bat

#7 Post by ShadowThief » 17 Jun 2017 09:56

Oh, that's what that does.

Everything goes really slow for me, and I have a very fast computer.

TheHunterManX
Posts: 54
Joined: 14 Aug 2015 05:59

Re: New batch tool: Cursortemplate.bat

#8 Post by TheHunterManX » 17 Jun 2017 10:11

ShadowThief wrote:Oh, that's what that does.

Everything goes really slow for me, and I have a very fast computer.


How much is Time set to? If Time is set to a high number, it will go slow since I use the "for /l" command.
Test batbox k_ to see if that is the problem of your slowness.
Is the cursor display, the display of PInput, or the input that is slow?
Is Inputx and Inputy set to nothing?
Are you using the button command? If so, test without the button command.
How fast is the for /l command?
How fast is your Harddrive?

I want to help, so anything will due.

Aacini
Expert
Posts: 1914
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: New batch tool: Cursortemplate.bat

#9 Post by Aacini » 17 Jun 2017 10:38

TheHunterManX wrote:- Yes, it can be used for menus, but there is more you can use it for.

Unfortunately, you have not explained until now what is the purpose of this program...

TheHunterManX wrote:I understand that some people don't understand how it works, so I will make a example of how to use this.
Example:

Code: Select all

snip...



A good example consists in an explanation of what the example is for and an explanation of how to use it. The code is the less important part of the example.


Perhaps you don't realize that this site is a forum of Batch file programmers. From that point of view, your following "explanations" are just useless:

TheHunterManX wrote:- To use this, put this file into the folder that you are going to run this in.

Code: Select all

:: I used setlocal because it allows for variables to be used on parse time, rather than execution time.
setlocal EnableDelayedExpansion
:: Calls preset1.
call :preset1
:: the beginning of the script.
:begin



I am sorry, but I stop reviewing your "example" at this point...

Antonio

ShadowThief
Expert
Posts: 1166
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: New batch tool: Cursortemplate.bat

#10 Post by ShadowThief » 17 Jun 2017 11:20

TheHunterManX wrote:
ShadowThief wrote:Oh, that's what that does.

Everything goes really slow for me, and I have a very fast computer.


How much is Time set to? If Time is set to a high number, it will go slow since I use the "for /l" command.
Test batbox k_ to see if that is the problem of your slowness.
Is the cursor display, the display of PInput, or the input that is slow?
Is Inputx and Inputy set to nothing?
Are you using the button command? If so, test without the button command.
How fast is the for /l command?
How fast is your Harddrive?

I want to help, so anything will due.

I just copied and pasted your example script without changing anything. I've got a solid state drive and a 3.50 GHz i5 6600K processor.

Image
That's in real time with no other applications running. Way, way too slow to be useful.

TheHunterManX
Posts: 54
Joined: 14 Aug 2015 05:59

Re: New batch tool: Cursortemplate.bat

#11 Post by TheHunterManX » 17 Jun 2017 11:47

ShadowThief wrote:
TheHunterManX wrote:
ShadowThief wrote:Oh, that's what that does.

Everything goes really slow for me, and I have a very fast computer.


How much is Time set to? If Time is set to a high number, it will go slow since I use the "for /l" command.
Test batbox k_ to see if that is the problem of your slowness.
Is the cursor display, the display of PInput, or the input that is slow?
Is Inputx and Inputy set to nothing?
Are you using the button command? If so, test without the button command.
How fast is the for /l command?
How fast is your Harddrive?

I want to help, so anything will due.

I just copied and pasted your example script without changing anything. I've got a solid state drive and a 3.50 GHz i5 6600K processor.

Image
That's in real time with no other applications running. Way, way too slow to be useful.

You're right that it is too slow to be useful. I have a normal hard drive that has lower specs then yours too. Could you test the following:

Code: Select all

@echo off
for /l %%A in (1,1,1000) do (echo %%A
)
echo Done!
pause

How much time did it take to echo Done?
If it took less then a few seconds then try

Code: Select all

@echo off
:begin
batbox /k_
if "%Errorlevel%" NEQ "0" echo %errorlevel%
goto begin

The number it outputs should be >0,3
Please give back feedback.

PaperTronics
Posts: 118
Joined: 02 Apr 2017 06:11

Re: New batch tool: Cursortemplate.bat

#12 Post by PaperTronics » 17 Jun 2017 11:50

So... All it does is just overlap a > on the cursor? I didn't go through the example code but if it can overlap the cursor with any letter it would be kinda cool. It works just as slow on my computer as it does on ShadowThief's.

Also I see that you're using the button function made by kvc (who is one my best friend). Pleasure to see that many programmers visit my website thebateam.org

ShadowThief
Expert
Posts: 1166
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: New batch tool: Cursortemplate.bat

#13 Post by ShadowThief » 17 Jun 2017 11:58

TheHunterManX wrote:You're right that it is too slow to be useful. I have a normal hard drive that has lower specs then yours too. Could you test the following:

Code: Select all

@echo off
for /l %%A in (1,1,1000) do (echo %%A
)
echo Done!
pause

How much time did it take to echo Done?

Running the script 20 or so times shows an average runtime of .03 seconds

TheHunterManX wrote:

Code: Select all

@echo off
:begin
batbox /k_
if "%Errorlevel%" NEQ "0" echo %errorlevel%
goto begin

The number it outputs should be >0,3
Please give back feedback.

This just hangs with no output at all, although if I press keys it returns their ASCII value

PaperTronics wrote:Pleasure to see that many programmers visit my website thebateam.org

It's extremely likely that they got the code from somewhere else

TheHunterManX
Posts: 54
Joined: 14 Aug 2015 05:59

Re: New batch tool: Cursortemplate.bat

#14 Post by TheHunterManX » 18 Jun 2017 00:32

Odd, if multiple people are having slowdowns with this tool, then I'm going to have to fix that. I will try to optimize the code the best I can. I will try this tool on other computer (a windows xp) to see if I get slowdowns as well.

TheHunterManX
Posts: 54
Joined: 14 Aug 2015 05:59

Re: New batch tool: Cursortemplate.bat

#15 Post by TheHunterManX » 18 Jun 2017 00:54

This is Cursortemplate.bat changed around a bit. Does this one improve the speed. If so, how much?
I tested this on windows xp and have confirmed compatibility.
Before, it was a bit laggy on the xp (had to wait like 2 seconds before it moved), now it goes a bit faster (~1 second). Now it goes faster on my Windows 10 as well.

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%&goto cursor
if "%Action%" EQU "Down" set /a TInput1=%TInput1%+%TInput5%&goto cursor
if "%Action%" EQU "Left" set /a TInput0=%TInput0%-%TInput4%&goto cursor
if "%Action%" EQU "Right" set /a TInput0=%TInput0%+%TInput4%&goto cursor
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%
goto :EOF)
batbox /g %1 %2 /d " "
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

Post Reply