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
Keyboard Input
Moderator: DosItHelp
Re: Keyboard Input
I don't have the program you are using ("keyboard"), but how about just testing the errorlevel with a small "test.bat":
penpen
Code: Select all
keyboard
echo errorlevel="%errorlevel%"
-
- Expert
- Posts: 1166
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: Keyboard Input
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.
Based on this chart, Enter should be 28.
Re: Keyboard Input
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
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
-
- Expert
- Posts: 1166
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: Keyboard Input
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.)
Re: Keyboard Input
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
Steffen