Skip to content

Commit d276a88

Browse files
committed
Updating IE driver to properly handle carriage return ('\r') character
1 parent 2e63ee6 commit d276a88

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

cpp/iedriver/InputManager.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -958,6 +958,10 @@ void InputManager::AddKeyboardInput(HWND window_handle, wchar_t character, bool
958958
this->UpdatePressedKeys(character, !key_up);
959959

960960
KeyInfo key_info = this->GetKeyInfo(window_handle, character);
961+
if (key_info.is_ignored_key) {
962+
return;
963+
}
964+
961965
if (!key_info.is_webdriver_key) {
962966
if (!key_info.scan_code || (key_info.key_code == 0xFFFFU)) {
963967
LOG(WARN) << "No translation for key. Assuming unicode input: " << character;
@@ -1046,8 +1050,11 @@ bool InputManager::IsModifierKey(wchar_t character) {
10461050

10471051
KeyInfo InputManager::GetKeyInfo(HWND window_handle, wchar_t character) {
10481052
KeyInfo key_info;
1053+
key_info.is_ignored_key = false;
10491054
key_info.is_extended_key = false;
10501055
key_info.is_webdriver_key = true;
1056+
key_info.key_code = 0;
1057+
key_info.scan_code = 0;
10511058
DWORD process_id = 0;
10521059
DWORD thread_id = ::GetWindowThreadProcessId(window_handle, &process_id);
10531060
HKL layout = ::GetKeyboardLayout(thread_id);
@@ -1283,7 +1290,7 @@ KeyInfo InputManager::GetKeyInfo(HWND window_handle, wchar_t character) {
12831290
key_info.scan_code = VK_RETURN;
12841291
}
12851292
else if (character == L'\r') { // carriage return
1286-
// skip it
1293+
key_info.is_ignored_key = true; // skip it
12871294
} else {
12881295
key_info.key_code = VkKeyScanExW(character, layout);
12891296
key_info.scan_code = MapVirtualKeyExW(LOBYTE(key_info.key_code), 0, layout);

cpp/iedriver/InputManager.h

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ struct KeyInfo {
3535
UINT scan_code;
3636
bool is_extended_key;
3737
bool is_webdriver_key;
38+
bool is_ignored_key;
3839
};
3940

4041
struct InputState {

0 commit comments

Comments
 (0)