1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

INKEY /M ???

Discussion in 'Support' started by vefatica, Apr 18, 2009.

  1. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,794
    Likes Received:
    29
    if I do this:

    inkey /m %%foo
    echo ##%foo##
    if "%key" EQ "d" echo LeftButton
    if %key EQ 240 echo LeftButton

    I see ##d## (and no message echoed). I'm baffled.

    I also suspect the third line below (help example) is wrong.

    inkey Enter a key: %%key
    if "%@ascii[%key]" == "27" echo Esc pressed
    if %key EQ 240 echo Left mouse button clicked
     
  2. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,280
    Likes Received:
    38
    You're naming your variable FOO in the first two lines, and KEY in the next two.
     
  3. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,794
    Likes Received:
    29
    On Sat, 18 Apr 2009 16:33:05 -0500, Charles Dye <> wrote:

    |---Quote (Originally by vefatica)---
    |if I do this:
    |
    |inkey /m %%foo
    |echo ##%foo##
    |if "%key" EQ "d" echo LeftButton
    |if %key EQ 240 echo LeftButton
    |
    |I see ##d## (and no message echoed). I'm baffled.
    |---End Quote---
    |You're naming your variable FOO in the first two lines, and KEY in the next two.
    |

    Having corrected that dumb mistake, it's still as I said.

    "%foo" is not a real "d"; neither is it 240.

    I'm not baffled any longer but the third line in the help's example still seems
    to be faulty.
    --
    - Vince
     
  4. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,280
    Likes Received:
    38
    Yes, the help example is defective. Better tests would be e.g.:

    <CODE>
    if %@ascii[%key] == 240 echo LeftButton
    if "%key" == "%@char[240]" echo LeftButton
    </CODE>

    If I'm not mistaken, that character is a lowercase eth. Which should appear somewhat similar to a lowercase D, but not so similar as Windows's console makes it! You could also insert this rune directly in your batch file's test by typing Alt-240 in Notepad, if you wanted to make your code unintelligible....
     

Share This Page