mirror of https://github.com/OpenVPN/openvpn-gui
Keep PLAP dialog alive by simulating user activity
Add a timer to periodically simulate mouse movement using SendInput, preventing the pre-logon UI from being dismissed due to inactivity during mobile QR code authentication. Signed-off-by: Lev Stipakov <lev@openvpn.net>pull/744/head
parent
3e4adfa49e
commit
4ff7980cfb
19
qr.c
19
qr.c
|
@ -97,6 +97,8 @@ INT_PTR CALLBACK
|
||||||
QrDialogProc(HWND hwnd, UINT msg, UNUSED WPARAM wp, LPARAM lp)
|
QrDialogProc(HWND hwnd, UINT msg, UNUSED WPARAM wp, LPARAM lp)
|
||||||
{
|
{
|
||||||
static HBITMAP hQRBitmap = NULL;
|
static HBITMAP hQRBitmap = NULL;
|
||||||
|
static UINT_PTR timerId = 1;
|
||||||
|
static UINT timerElapse = 20000; /* must be less than 30 sec pre-logon timeout */
|
||||||
|
|
||||||
switch (msg)
|
switch (msg)
|
||||||
{
|
{
|
||||||
|
@ -172,6 +174,8 @@ QrDialogProc(HWND hwnd, UINT msg, UNUSED WPARAM wp, LPARAM lp)
|
||||||
SetWindowText(hwnd, uc->config_name);
|
SetWindowText(hwnd, uc->config_name);
|
||||||
|
|
||||||
g_hwndQR = hwnd;
|
g_hwndQR = hwnd;
|
||||||
|
|
||||||
|
SetTimer(hwnd, timerId, timerElapse, NULL);
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
|
@ -179,10 +183,25 @@ QrDialogProc(HWND hwnd, UINT msg, UNUSED WPARAM wp, LPARAM lp)
|
||||||
EndDialog(hwnd, 0);
|
EndDialog(hwnd, 0);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
|
case WM_TIMER:
|
||||||
|
if (wp == timerId)
|
||||||
|
{
|
||||||
|
/* Simulate mouse movement to keep Winlogon from dismissing the PLAP dialog */
|
||||||
|
INPUT input = { 0 };
|
||||||
|
input.type = INPUT_MOUSE;
|
||||||
|
input.mi.dwFlags = MOUSEEVENTF_MOVE;
|
||||||
|
input.mi.dx = 0;
|
||||||
|
input.mi.dy = 0;
|
||||||
|
SendInput(1, &input, sizeof(INPUT));
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
case WM_DESTROY:
|
case WM_DESTROY:
|
||||||
if (hQRBitmap)
|
if (hQRBitmap)
|
||||||
DeleteObject(hQRBitmap);
|
DeleteObject(hQRBitmap);
|
||||||
g_hwndQR = NULL;
|
g_hwndQR = NULL;
|
||||||
|
|
||||||
|
KillTimer(hwnd, timerId);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
Loading…
Reference in New Issue