Skip to content

Commit 730841f

Browse files
committed
final changes, we are ready to test with SM-2201
1 parent 9d675e8 commit 730841f

File tree

3 files changed

+31
-23
lines changed

3 files changed

+31
-23
lines changed

MossbauerLab.Sm2201.ExtSaveUtility/src/saveManager/autoSaveManager.cpp

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

MossbauerLab.Sm2201.ExtSaveUtility/src/saveManager/autoSaveManager.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ namespace MossbauerLab
2929
void reloadConfig();
3030
void sendKeysSequence(HWND window, int channel, int technology = 0);
3131
private:
32+
void activateWindow(HWND window);
3233
void sendKeysViaWindowMsg(HWND window, const std::vector<DWORD>& keys, int keyPause = 500);
3334
// HERE we send scancodes from group 1
3435
void sendKeysViaKeyboardController(const std::vector<BYTE>& scanCodes, int keyPause = 500);

MossbauerLab.Sm2201.ExtSaveUtility/src/utils/windows/vxdAccessor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ bool MossbauerLab::Utils::Windows::VxDAccessor::init()
2020
{
2121
_hVxD = CreateFile(_T("\\\\.\\DIO_W55"), 0, 0, 0,
2222
CREATE_NEW, FILE_FLAG_DELETE_ON_CLOSE, 0);
23-
DWORD errCode = GetLastError();
23+
// DWORD errCode = GetLastError();
2424
return _hVxD != INVALID_HANDLE_VALUE;
2525
}
2626

0 commit comments

Comments
 (0)