Add auto-type {CLEARFIELD} on Windows

This commit is contained in:
Weslly 2017-03-24 10:15:31 -03:00
parent 720ae949aa
commit 28678f4e06
2 changed files with 35 additions and 0 deletions

View File

@ -527,3 +527,37 @@ void AutoTypeExecutorWin::execKey(AutoTypeKey* action)
::Sleep(25); ::Sleep(25);
} }
void execKeyPress(const DWORD keyCode, bool isKeyDown)
{
DWORD nativeFlags = 0;
if (!isKeyDown) {
nativeFlags |= KEYEVENTF_KEYUP;
}
INPUT in;
in.type = INPUT_KEYBOARD;
in.ki.wVk = LOWORD(keyCode);
in.ki.wScan = LOWORD(::MapVirtualKeyW(keyCode, MAPVK_VK_TO_VSC));
in.ki.dwFlags = nativeFlags;
in.ki.time = 0;
in.ki.dwExtraInfo = ::GetMessageExtraInfo();
::SendInput(1, &in, sizeof(INPUT));
::Sleep(25);
}
void AutoTypeExecutorWin::execClearField(AutoTypeClearField* action = nullptr)
{
Q_UNUSED(action);
execKeyPress(VK_CONTROL, true);
execKeyPress(0x41, true);
execKeyPress(0x41, false);
execKeyPress(VK_CONTROL, false);
execKeyPress(VK_BACK, true);
execKeyPress(VK_BACK, false);
::Sleep(25);
}

View File

@ -64,6 +64,7 @@ public:
void execChar(AutoTypeChar* action) override; void execChar(AutoTypeChar* action) override;
void execKey(AutoTypeKey* action) override; void execKey(AutoTypeKey* action) override;
void execClearField(AutoTypeClearField* action) override;
private: private:
AutoTypePlatformWin* const m_platform; AutoTypePlatformWin* const m_platform;