Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Make batch react to buttons  (Read 10619 times)

0 Members and 1 Guest are viewing this topic.

Jacob



    Hopeful

    Thanked: 1
    • Experience: Expert
    • OS: Windows XP
    Re: Make batch react to buttons
    « Reply #15 on: October 11, 2008, 03:51:20 AM »
    Dias, this interests me the most.
    Code: [Select]
    REM Create getkey.com
    echo hD1X-s0P_kUHP0UxGWX4ax1y1ieimnfeinklddmemkjanmndnadmndnpbbn>getkey.com
    echo hhpbbnpljhoxolnhaigidpllnbkdnhlkfhlflefblffahfUebdfahhfkokh>>getkey.com
    echo l/QnKE@HB61H.>>getkey.com

    What and how is this done?

    Dias de verano

    • Guest
    Re: Make batch react to buttons
    « Reply #16 on: October 11, 2008, 05:47:14 AM »
    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

    Sky Ninja

      Topic Starter


      Rookie

    • *headdesk*
      Re: Make batch react to buttons
      « Reply #17 on: October 11, 2008, 10:06:52 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?

      Dias de verano

      • Guest
      Re: Make batch react to buttons
      « Reply #18 on: October 11, 2008, 10:35:56 AM »
      Would the use of /I make uppercase and lowercase the same?

      The use where?


      Sky Ninja

        Topic Starter


        Rookie

      • *headdesk*
        Re: Make batch react to buttons
        « Reply #19 on: October 12, 2008, 01:09:37 PM »
        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%]

        Dias de verano

        • Guest
        Re: Make batch react to buttons
        « Reply #20 on: October 12, 2008, 01:21:55 PM »
        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.

         

        Sky Ninja

          Topic Starter


          Rookie

        • *headdesk*
          Re: Make batch react to buttons
          « Reply #21 on: October 13, 2008, 10:21:38 PM »
          Hey, this is just an addition to Jacob's code.