Keyboard Input

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Q. April
Posts: 19
Joined: 27 Jan 2018 14:36
Location: Mayatopia

Keyboard Input

#1 Post by Q. April » 27 Jan 2018 15:10

what code for ENTER

:controls
cls
echo.
echo.
echo.
keyboard
If "%errorlevel%"=="72" call:up
If "%errorlevel%"=="75" call:left
If "%errorlevel%"=="77" call:right
If "%errorlevel%"=="80" call:down
If "%errorlevel%"==" ???? " call:enter

penpen
Expert
Posts: 2009
Joined: 23 Jun 2013 06:15
Location: Germany

Re: Keyboard Input

#2 Post by penpen » 27 Jan 2018 19:16

I don't have the program you are using ("keyboard"), but how about just testing the errorlevel with a small "test.bat":

Code: Select all

keyboard
echo errorlevel="%errorlevel%"
penpen

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

Re: Keyboard Input

#3 Post by ShadowThief » 27 Jan 2018 20:53

I googled "keyboard codes" and it took a while, but I eventually found a chart where up was 72, left was 75, right was 77, and down was 80. http://www.vitsoft.info/opta-ssp.gif

Based on this chart, Enter should be 28.

Q. April
Posts: 19
Joined: 27 Jan 2018 14:36
Location: Mayatopia

Re: Keyboard Input

#4 Post by Q. April » 28 Jan 2018 05:51

Thank lol

Q. April
Posts: 19
Joined: 27 Jan 2018 14:36
Location: Mayatopia

Re: Keyboard Input

#5 Post by Q. April » 28 Jan 2018 11:12

Thank lol ,its really helped

from your sugestion ,I added couple code


@echo off
:test
cls
keyboard
echo errorlevel="%errorlevel%"
set /p key=
echo %errorlevel% = %key% >>test.txt
goto test


...Result from test.txt...

65 = A
66 = B
67 = C
68 = D
69 = E
70 = F
71 = G
72 = H
73 = I
74 = J
75 = K
76 = L
77 = M
78 = N
79 = O
80 = P
81 = Q
82 = R
83 = S
84 = T
85 = U
86 = V
87 = W
88 = X
89 = Y
90 = Z

97 = a
98 = b
99 = c
100 = d
101 = e
102 = f
103 = g
104 = h
105 = i
106 = j
107 = k
108 = l
109 = m
110 = n
111 = o
112 = p
113 = q
114 = r
115 = s
116 = t
117 = u
118 = v
119 = w
120 = x
121 = y
122 = z

48 = 0
49 = 1
50 = 2
51 = 3
52 = 4
53 = 5
54 = 6
55 = 7
56 = 8
57 = 9

33 = !
64 = @
35 = #
36 = $
37 = %
94 = ^
37 = %
94 =
42 = *
40 = (
41 = )
95 = _
43 = +
45 = -
61 = =

44 = ,
46 = .
47 = /
59 = ;
39 = '
92 = \
91 = [
93 = ]
45 = -
61 = =
58 = :
34 = "
123 = {
125 = }
95 = _
43 = +

75 = left
77 = right
72 = up
80 = down

13 = enter
32 = space

9 = tab
79 = end
81 = page down
73 = page up
71 = home
82 = delete

59 = f1
60 = f2
61 = f3
62 = f4
63 = f5
64 = f6
65 = f7
66 = f8
67 = f9
68 = f10
133 = f11
134 = f12


Not 28 but 13,BTW THANK for wasted your time to help me

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

Re: Keyboard Input

#6 Post by ShadowThief » 28 Jan 2018 13:27

Oh look, it's just regular ASCII values. Should have seen that coming. (Also, I'm going to assume that last sentence is a mistranslation and say you're welcome.)

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Keyboard Input

#7 Post by aGerman » 28 Jan 2018 14:32

This tool returns ambiguous results though. Rather use GetKey.exe of Aacini's tool collection. In order to differentate from ASCII values it returns negative values for function keys or arrow keys instead.

Steffen

Post Reply