mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-05-31 06:13:55 +00:00
add esc support fix #105
This commit is contained in:
parent
b9836d769a
commit
9503875953
@ -30,30 +30,38 @@ void dispatch_proc(iohook_event * const event) {
|
||||
case EVENT_KEY_PRESSED:
|
||||
// If the escape key is pressed, naturally terminate the program.
|
||||
if (event->data.keyboard.keycode == VC_ESCAPE) {
|
||||
int status = hook_stop();
|
||||
switch (status) {
|
||||
// System level errors.
|
||||
case IOHOOK_ERROR_OUT_OF_MEMORY:
|
||||
loggerProc(LOG_LEVEL_ERROR, "Failed to allocate memory. (%#X)", status);
|
||||
break;
|
||||
// int status = hook_stop();
|
||||
// switch (status) {
|
||||
// // System level errors.
|
||||
// case IOHOOK_ERROR_OUT_OF_MEMORY:
|
||||
// loggerProc(LOG_LEVEL_ERROR, "Failed to allocate memory. (%#X)", status);
|
||||
// break;
|
||||
|
||||
case IOHOOK_ERROR_X_RECORD_GET_CONTEXT:
|
||||
// NOTE This is the only platform specific error that occurs on hook_stop().
|
||||
loggerProc(LOG_LEVEL_ERROR, "Failed to get XRecord context. (%#X)", status);
|
||||
break;
|
||||
// case IOHOOK_ERROR_X_RECORD_GET_CONTEXT:
|
||||
// // NOTE This is the only platform specific error that occurs on hook_stop().
|
||||
// loggerProc(LOG_LEVEL_ERROR, "Failed to get XRecord context. (%#X)", status);
|
||||
// break;
|
||||
|
||||
// Default error.
|
||||
case IOHOOK_FAILURE:
|
||||
default:
|
||||
loggerProc(LOG_LEVEL_ERROR, "An unknown hook error occurred. (%#X)", status);
|
||||
break;
|
||||
}
|
||||
// // Default error.
|
||||
// case IOHOOK_FAILURE:
|
||||
// default:
|
||||
// loggerProc(LOG_LEVEL_ERROR, "An unknown hook error occurred. (%#X)", status);
|
||||
// break;
|
||||
// }
|
||||
}
|
||||
case EVENT_KEY_RELEASED:
|
||||
snprintf(buffer + length, sizeof(buffer) - length,
|
||||
",keycode=%u,rawcode=0x%X",
|
||||
event->data.keyboard.keycode, event->data.keyboard.rawcode);
|
||||
int akeyCode = (uint16_t) event->data.keyboard.keycode;
|
||||
|
||||
if (event->data.keyboard.keycode == VC_ESCAPE
|
||||
&& atoi(cevent) == 11) {
|
||||
int stopEvent = stop_event();
|
||||
// printf("stop_event%d\n", stopEvent);
|
||||
cstatus = 0;
|
||||
}
|
||||
|
||||
// printf("atoi(str)---%d\n", atoi(cevent));
|
||||
if (akeyCode == atoi(cevent)){
|
||||
int stopEvent = stop_event();
|
||||
|
@ -1111,6 +1111,7 @@ func AddEvent(aeve string) int {
|
||||
"f11": "69",
|
||||
"f12": "70",
|
||||
// more
|
||||
"esc": "11",
|
||||
"tab": "15",
|
||||
"ctrl": "29",
|
||||
"control": "29",
|
||||
|
Loading…
Reference in New Issue
Block a user