|< 1 2 >| | 13 Einträge, 2 Seiten |
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
use Win32::GuiTest qw/SendKeys IsKeyPressed/;
my @keys = qw/1 2 3 x y z ESC/;
my $logfile = "logfile_eingaben.txt";
open LOGFILE, ">> $logfile";
#until (IsKeyPressed("1")&&("2")) {
until (IsKeyPressed("ESC")) {
for (@keys) {
if (IsKeyPressed($_)) {
print LOG "$_ wurde gedrückt\n";
SendKeys "{PAUSE 1}";
}
elsif (IsKeyPressed("Strg"))
{
print LOG " $_ gedrückt\n";
SendKeys "{PAUSE 1}";
}
else {
SendKeys "{PAUSE 1}";
}
}
}
close LOGFILE;
1
2
3
4
5
6
7
use Win32::GuiTest qw/SendKeys IsKeyPressed :VK/;
[...]
if (IsKeyPressed(VK_SHIFT)) { # bzw. VK_ALT / VK_CONTROL
print LOG "SHIFT wurde gedrückt\n";
SendKeys "{PAUSE 1}";
}
[...]
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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
441a442,453
> BOOL IsDigitString(const char *s)
> {
> if(s == NULL || *s == 0)
> return FALSE;
>
> while(*s && isdigit(*s)) {
> s++;
> }
>
> return *s == 0 ? TRUE : FALSE;
> }
>
1503,1504c1515,1516
< if (len >= 3)
< name[3]=NUL;
---
> /*if (len >= 3)
> name[3]=NUL;*/
1508a1521,1523
> } else if (IsDigitString(name)) {
> OutputDebugString("Trying integer\n");
> RETVAL = GetAsyncKeyState(atoi(name));
|< 1 2 >| | 13 Einträge, 2 Seiten |