auto-obs-rb-restart/monitor.c
Mylloon 5bd7ff14e2
All checks were successful
Upload release / build (push) Successful in 2m37s
fix time
2024-10-07 21:20:48 +02:00

26 lines
653 B
C

#include <time.h>
#include <windows.h>
static DWORD last_input_time = 0; // Store the last input time in milliseconds
HHOOK hKeyboardHook;
LRESULT CALLBACK KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam) {
if (nCode == HC_ACTION) {
last_input_time = time(NULL);
}
return CallNextHookEx(hKeyboardHook, nCode, wParam, lParam);
}
__declspec(dllexport) void start_hook(void) {
hKeyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, KeyboardHookProc, NULL, 0);
}
__declspec(dllexport) void stop_hook(void) {
UnhookWindowsHookEx(hKeyboardHook);
}
__declspec(dllexport) int last_time_input_received(void) {
return last_input_time;
}