INKEY /M ???

#1
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
 
#3
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
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
3,575
46
Albuquerque, NM
prospero.unm.edu
#4
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....