From ee8d9312dec663d3c20b7e5f8b9c0c5b9053f63a Mon Sep 17 00:00:00 2001 From: Frank Fesevur Date: Mon, 11 Apr 2016 22:03:32 +0200 Subject: [PATCH] Fill the username field with the current Windows username And after that put the focus on the password field --- openvpn.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/openvpn.c b/openvpn.c index 2903b58..6d31284 100644 --- a/openvpn.c +++ b/openvpn.c @@ -236,6 +236,15 @@ UserAuthDialogFunc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) if(param->challenge_echo) SendMessage(wnd_challenge, EM_SETPASSWORDCHAR, 0, 0); } + /* Fill the username field with the current Windows username and put the focus on the password field */ + WCHAR username[MAX_PATH]; + DWORD usernamesize = MAX_PATH; + if (GetUserName(username, &usernamesize)) + { + SetDlgItemText(hwndDlg, ID_EDT_AUTH_USER, username); + SendMessage(hwndDlg, WM_NEXTDLGCTL, (WPARAM) GetDlgItem(hwndDlg, ID_EDT_AUTH_PASS), TRUE); + } + if (param->c->state == resuming) ForceForegroundWindow(hwndDlg); else