1.

Solve : Make batch react to buttons?

Answer»

Dias, this interests me the most.
Code: [Select]REM Create getkey.com
echo hD1X-s0P_kUHP0UxGWX4ax1y1ieimnfeinklddmemkjanmndnadmndnpbbn>getkey.com
echo hhpbbnpljhoxolnhaigidpllnbkdnhlkfhlflefblffahfUebdfahhfkokh>>getkey.com
echo l/[emailprotected]>>getkey.com

What and how is this done?A .com program is an 8086 assembly language program for running under MS-DOS. The effect of the lines you quoted is to create such a (previously written) program byte by byte. What the program does is

1. wait for a keypress
2. place the ascii value into errorlevel
3. exit
Quote from: Dias DE verano on October 11, 2008, 03:31:08 AM

1. Your code only works for lowercase letters of the alphabet 'a' to 'z'.

2. But you show uppercase letters to the USER. ASCII 97 is 'a' not 'A'. The keypress program gives a different code if a key is shifted or if Caps Lock is operative.
Would the use of /I make uppercase and lowercase the same?Quote from: Sky Ninja on October 11, 2008, 10:06:52 AM
Would the use of /I make uppercase and lowercase the same?

The use where?

Nevermind, it wouldn't. I meant in the if's.
Anyway, I figured out how to get new errorlevel settings.
Code: [Select]set key=%errorlevel%
[b]echo %errorlevel% >C:\errorlevel.txt[/b]
REM ASCII value of key is contained in %Key% Press a known key, then press an unknown key, and if it's different from the known key, you've got a new errorlevel.
Code: [Select]If %Key%==48 echo 0 [%Key%]
If %Key%==49 echo 1 [%Key%]
If %Key%==50 echo 2 [%Key%]
If %Key%==51 echo 3 [%Key%]
If %Key%==52 echo 4 [%Key%]
If %Key%==53 echo 5 [%Key%]
If %Key%==54 echo 6 [%Key%]
If %Key%==55 echo 7 [%Key%]
If %Key%==56 echo 8 [%Key%]
If %Key%==57 echo 9 [%Key%]
::----------------------------------------------------------
If %Key%==13 echo ENTER [%Key%]
::----------------------------------------------------------
If %Key%==27 echo Escape [%Key%]Without wishing to be horrible, I will point out that code which contains a zillion lines like this:

Code: [Select]IF X = 1 goto one
IF X = 2 goto two

[...]

IF X = 254 goto twofivefour
IF X = 255 goto twofivefive

(etc)


... is generally the mark of the beginning coder. Sometimes it cannot be avoided, but it is much better to find a more compact SOLUTION, which I already have shown.

Hey, this is just an addition to Jacob's code.


Discussion

No Comment Found