@@ -223,9 +223,8 @@ void MossbauerLab::Sm2201::SaveManager::AutoSaveManager::reloadConfig()
223223 _config->reload ();
224224}
225225
226- void MossbauerLab::Sm2201::SaveManager::AutoSaveManager::sendKeysSequence (HWND window, int channel, int technology )
226+ void MossbauerLab::Sm2201::SaveManager::AutoSaveManager::activateWindow (HWND window)
227227{
228- // 0. make window active
229228 /* INPUT keyBoardInput;
230229 keyBoardInput.type = INPUT_KEYBOARD;
231230 keyBoardInput.ki.wScan = 0;
@@ -240,25 +239,33 @@ void MossbauerLab::Sm2201::SaveManager::AutoSaveManager::sendKeysSequence(HWND w
240239 keyBoardInput.ki.dwFlags = 2; // key up
241240 SendInput(1, &keyBoardInput, sizeof(INPUT));*/
242241
243- std::vector<DWORD> charCodes;
244- if (channel == 1 )
245- charCodes.push_back (VK_LEFT);
246- else charCodes.push_back (VK_RIGHT);
247- charCodes.push_back (0x43 ); // continue
248- charCodes.push_back (VK_RETURN); // scaling coeff
249- charCodes.push_back (VK_RETURN); // stop update
250- charCodes.push_back (0x57 ); // write
251- charCodes.push_back (VK_RETURN); // submit name
252- charCodes.push_back (VK_RETURN); // submit overwrite
242+ SendMessage (window, WM_ACTIVATE, WA_CLICKACTIVE, 0 );
243+ }
244+
245+ void MossbauerLab::Sm2201::SaveManager::AutoSaveManager::sendKeysSequence (HWND window, int channel, int technology)
246+ {
247+ // 0. make window active
248+ activateWindow (window);
249+
250+ if (technology == WINDOWS_MSG || technology == SEND_INPUT) // sending via Windows MSG
251+ {
252+ std::vector<DWORD> charCodes;
253+ if (channel == 1 )
254+ charCodes.push_back (VK_LEFT);
255+ else charCodes.push_back (VK_RIGHT);
256+ charCodes.push_back (0x43 ); // continue
257+ charCodes.push_back (VK_RETURN); // scaling coeff
258+ charCodes.push_back (VK_RETURN); // stop update
259+ charCodes.push_back (0x57 ); // write
260+ charCodes.push_back (VK_RETURN); // submit name
261+ charCodes.push_back (VK_RETURN); // submit overwrite
262+
263+ if (technology == WINDOWS_MSG)
264+ sendKeysViaWindowMsg (window, charCodes);
265+ else
266+ sendKeysViaInput (charCodes);
267+ }
253268
254- if (technology == WINDOWS_MSG) // sending via Windows MSG
255- {
256- sendKeysViaWindowMsg (window, charCodes);
257- }
258- else if (technology == SEND_INPUT)
259- {
260- sendKeysViaInput (charCodes);
261- }
262269 else if (technology == DIRECT_PORT_WRITE)
263270 {
264271 std::vector<BYTE> scanCodes;
@@ -376,13 +383,13 @@ void MossbauerLab::Sm2201::SaveManager::AutoSaveManager::sendKeysViaPortVxdDrive
376383 _vxdAccessor->write (KEYBOARD_CMD_REG, 0xD2 , 1 );
377384 _vxdAccessor->write (KEYBOARD_DATA_REG, (*it), 1 );
378385 result = _vxdAccessor->read (KEYBOARD_DATA_REG, 1 );
379- std::cout <<" Keyboard command result for KEY DOWN: " << result << std::endl;
386+ // std::cout <<"Keyboard command result for KEY DOWN: "<< result << std::endl;
380387 // send scan code for key up
381388 BYTE keyUpCode = (*it) | 128 ;
382389 Sleep (keyPause);
383390 _vxdAccessor->write (KEYBOARD_CMD_REG, 0xD2 , 1 );
384391 _vxdAccessor->write (KEYBOARD_DATA_REG, keyUpCode, 1 );
385392 result = _vxdAccessor->read (KEYBOARD_DATA_REG, 1 );
386- std::cout <<" Keyboard command result for KEY UP: " << result << std::endl;
393+ // std::cout <<"Keyboard command result for KEY UP: "<< result << std::endl;
387394 }
388395}
0 commit comments