比这篇新的文章:
抓取糗事百科前100页的Python脚本
比这篇旧的文章: java
作者: Gohan, 点击445次, 评论(0), 收藏者(0)
打分:
所有评论,共0条:( 我也来说两句)
比这篇旧的文章: java
GohanConsoleHelper
语言: C++, 标签: 无 2008/05/23发布 5个月前更新作者: Gohan, 点击445次, 评论(0), 收藏者(0)
C++语言: GohanConsoleHelper
01 #pragma once
02
03 #include <Windows.h>
04
05 class GohanConsoleHelper
06
07 {
08
09 HANDLE _hIn;
10
11 HANDLE _hOut;
12
13 INPUT_RECORD _InRec;
14
15 DWORD _NumRead;
16
17 public:
18
19 WORD VKey;
20
21 GohanConsoleHelper(void){
22
23 _hIn = GetStdHandle(STD_INPUT_HANDLE);
24
25 _hOut = GetStdHandle(STD_OUTPUT_HANDLE);
26
27 VKey=0;
28
29 }
30
31 bool ReadOneInput()
32
33 {
34
35 return 0!=ReadConsoleInput(_hIn,&_InRec,1,&_NumRead);
36
37 }
38
39 bool ReadOneInput(INPUT_RECORD& InRec)
40
41 {
42
43 return 0!=ReadConsoleInput(_hIn,&InRec,1,&_NumRead);
44
45 }
46
47 DWORD ReadKeyDown()
48
49 {
50
51 if(!ReadConsoleInput(_hIn,&_InRec,1,&_NumRead))
52
53 return 0;
54
55 if(_InRec.EventType!=KEY_EVENT)
56
57 return 0;
58
59 if(_InRec.Event.KeyEvent.bKeyDown > 0)
60
61 return 0;
62
63 VKey = _InRec.Event.KeyEvent.wVirtualKeyCode;
64
65 return VKey;
66
67 }
68
69 DWORD ReadKeyPush()
70
71 {
72
73 if(!ReadConsoleInput(_hIn,&_InRec,1,&_NumRead))
74
75 return 0;
76
77 if(_InRec.EventType!=KEY_EVENT)
78
79 return 0;
80
81 if(_InRec.Event.KeyEvent.bKeyDown == 0)
82
83 return 0;
84
85 VKey = _InRec.Event.KeyEvent.wVirtualKeyCode;
86
87 return VKey;
88
89 }
90
91 public:
92
93 ~GohanConsoleHelper(void){}
94
95 };
02
03 #include <Windows.h>
04
05 class GohanConsoleHelper
06
07 {
08
09 HANDLE _hIn;
10
11 HANDLE _hOut;
12
13 INPUT_RECORD _InRec;
14
15 DWORD _NumRead;
16
17 public:
18
19 WORD VKey;
20
21 GohanConsoleHelper(void){
22
23 _hIn = GetStdHandle(STD_INPUT_HANDLE);
24
25 _hOut = GetStdHandle(STD_OUTPUT_HANDLE);
26
27 VKey=0;
28
29 }
30
31 bool ReadOneInput()
32
33 {
34
35 return 0!=ReadConsoleInput(_hIn,&_InRec,1,&_NumRead);
36
37 }
38
39 bool ReadOneInput(INPUT_RECORD& InRec)
40
41 {
42
43 return 0!=ReadConsoleInput(_hIn,&InRec,1,&_NumRead);
44
45 }
46
47 DWORD ReadKeyDown()
48
49 {
50
51 if(!ReadConsoleInput(_hIn,&_InRec,1,&_NumRead))
52
53 return 0;
54
55 if(_InRec.EventType!=KEY_EVENT)
56
57 return 0;
58
59 if(_InRec.Event.KeyEvent.bKeyDown > 0)
60
61 return 0;
62
63 VKey = _InRec.Event.KeyEvent.wVirtualKeyCode;
64
65 return VKey;
66
67 }
68
69 DWORD ReadKeyPush()
70
71 {
72
73 if(!ReadConsoleInput(_hIn,&_InRec,1,&_NumRead))
74
75 return 0;
76
77 if(_InRec.EventType!=KEY_EVENT)
78
79 return 0;
80
81 if(_InRec.Event.KeyEvent.bKeyDown == 0)
82
83 return 0;
84
85 VKey = _InRec.Event.KeyEvent.wVirtualKeyCode;
86
87 return VKey;
88
89 }
90
91 public:
92
93 ~GohanConsoleHelper(void){}
94
95 };
所有评论,共0条:( 我也来说两句)
代码