MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / GetSwitchingKeysForEngine

Method GetSwitchingKeysForEngine

cpp/imehandler/windows/src/winapihandler.cc:322–387  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

320}
321
322std::string WinapiHandler::GetSwitchingKeysForEngine(std::string engine) {
323 std::string keys = "";
324 HKEY key;
325 if (RegOpenKeyEx(HKEY_CURRENT_USER,
326 TEXT("Control Panel\\Input Method\\Hot Keys"),
327 0,
328 KEY_ENUMERATE_SUB_KEYS|KEY_QUERY_VALUE, &key)
329 ==ERROR_SUCCESS) {
330 TCHAR subkey_buffer[MAX_KEY_LENGTH];
331 DWORD subname_size = 0;
332 DWORD nb_subkeys = 0;
333
334 // Get the class name and the value count.
335 if (RegQueryInfoKey(key, // key handle
336 NULL, // buffer for class name
337 NULL, // size of class string
338 NULL, // reserved
339 &nb_subkeys, // number of subkeys
340 NULL, // longest subkey size
341 NULL, // longest class string
342 NULL, // number of values for this key
343 NULL, // longest value name
344 NULL, // longest value data
345 NULL, // security descriptor
346 NULL) // last write time
347 == ERROR_SUCCESS) {
348 // Enumerate the subkeys, until RegEnumKeyEx fails.
349 if (nb_subkeys > 0) {
350 for (unsigned int i = 0; i < nb_subkeys; i++) {
351 subname_size = MAX_KEY_LENGTH;
352 if (RegEnumKeyEx(key, i, subkey_buffer, &subname_size,
353 NULL, NULL, NULL, NULL) == ERROR_SUCCESS) {
354 DWORD modifiers = 0;
355 DWORD target_IME = 0;
356 DWORD virtual_key = 0;
357 DWORD nb_bytes = sizeof(modifiers);
358 if (RegGetValue(key, subkey_buffer, "Target IME", RRF_RT_ANY,
359 NULL, &target_IME, &nb_bytes) == ERROR_SUCCESS
360 && (target_IME != 0)) {
361 std::stringstream hkl;
362 hkl << std::hex << std::setw(8) << std::setfill('0') <<
363 target_IME;
364 std::string layout_hkl = GetLayoutHkl(engine);
365 if (layout_hkl.find("0000") == 0) {
366 layout_hkl = layout_hkl.substr(4)+ layout_hkl.substr(4);
367 }
368 if (hkl.str() == layout_hkl) {
369 RegGetValue(key, subkey_buffer, "Key Modifiers", RRF_RT_ANY,
370 NULL, &modifiers, &nb_bytes);
371 RegGetValue(key, subkey_buffer, "Virtual Key", RRF_RT_ANY,
372 NULL, &virtual_key, &nb_bytes);
373 // Reset the string stream to build the resulting string.
374 hkl.str("");
375 hkl << GetModifiers(modifiers) << "+" <<
376 static_cast<char>(virtual_key);
377 keys = hkl.str();
378 }
379 }

Callers

nothing calls this directly

Calls 2

findMethod · 0.80
strMethod · 0.80

Tested by

no test coverage detected