Thread Win32::GuiTest: IsKeyPressed(shift strg...) (12 answers)
Opened by landogar at 2005-12-13 16:53

esskar
 2005-12-14 14:15
#60878 #60878
User since
2003-08-04
7321 Artikel
ModeratorIn

user image
das ding ist doof implementiert:

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
int findvkey(const char* name, int* key) 
{
/* symbol table record */
typedef struct tokentable {
char *token;
int vkey;
} tokentable;

/* global symbol table */
static tokentable tbl[] = {
"BAC", VK_BACK,
"BS" , VK_BACK,
"BKS", VK_BACK,
"BRE", VK_CANCEL,
"CAP", VK_CAPITAL,
"DEL", VK_DELETE,
"DOW", VK_DOWN,
"END", VK_END,
"ENT", VK_RETURN,
"ESC", VK_ESCAPE,
"HEL", VK_HELP,
"HOM", VK_HOME,
"INS", VK_INSERT,
"LEF", VK_LEFT,
"NUM", VK_NUMLOCK,
"PGD", VK_NEXT,
"PGU", VK_PRIOR,
"PRT", VK_SNAPSHOT,
"RIG", VK_RIGHT,
"SCR", VK_SCROLL,
"TAB", VK_TAB,
"UP", VK_UP,
"F1", VK_F1,
"F2", VK_F2,
"F3", VK_F3,
"F4", VK_F4,
"F5", VK_F5,
"F6", VK_F6,
"F7", VK_F7,
"F8", VK_F8,
"F9", VK_F9,
"F10", VK_F10,
"F11", VK_F11,
"F12", VK_F12,
"F13", VK_F13,
"F14", VK_F14,
"F15", VK_F15,
"F16", VK_F16,
"F17", VK_F17,
"F18", VK_F18,
"F19", VK_F19,
"F20", VK_F20,
"F21", VK_F21,
"F22", VK_F22,
"F23", VK_F23,
"F24", VK_F24,
"SPC", VK_SPACE,
"SPA", VK_SPACE,
"LWI", VK_LWIN,
"RWI", VK_RWIN,
"APP", VK_APPS,
};
int i;
for (i=0;i<sizeof(tbl)/sizeof(tokentable);i++) {
if (strcmp(tbl[i].token, name)==0) {
*key=tbl[i].vkey;
return 1;
}
}
return 0;
}

BOOL
IsKeyPressed(name)
char* name;
CODE:
int vkey;
int found;
int len = strlen(name);
if (len >= 3)
name[3]=NUL;
found = findvkey(name, &vkey);
if (found) {
OutputDebugString("Trying key\n");
RETVAL = GetAsyncKeyState(vkey);
} else if (strlen(name)==1 && (isdigit(*name) || isalpha(*name))) {
OutputDebugString("Trying alphanum\n");
RETVAL = GetAsyncKeyState(toupper(*name));
}else {
OutputDebugString("No key\n");
RETVAL = 0;
}
OUTPUT:
RETVAL


wie man sieht, kann es nicht gehen, da in findvkey nix von SHIFT definiert ist ... leider!

View full thread Win32::GuiTest: IsKeyPressed(shift strg...)