Page 1 of 1

HotKey pressing from another application

Posted: 15 Jan 2019 15:13
by Nikxp
I want to emulate hotkey's click from my application. There are 2 problems.
1) if i changed Windows system language (on Russian for example) hotKeys doesn't work at all.
2) To solve 1) problem i use SendInput function (https://docs.microsoft.com/en-us/window ... -sendinput) with wScan field with KEYEVENTF_UNICODE flag. But when i use code below strange thing are happend: when i clicked "f" VLC fullscreened, but after this on "m" click it doesn't Mute, but cancel fullscreen mode. If i started by "m" hotkey, then all other clicks will Mute/Unmute VLC.

How can i use fullscreen/ Mute and other functions from my app, when systemLanguage is Russian?

Code: Select all

void WindowsKeyClickEmulator::_clickKey(WORD key) { _pressKey(key); _releaseKey(key); } int oddIndex = 0; void WindowsKeyClickEmulator::_pressKey(WORD key) { QChar symbol; if( ++oddIndex % 2) { symbol = 'f'; } else { symbol = 'm'; } INPUT ip; ip.type = INPUT_KEYBOARD; ip.ki.wScan = symbol.unicode(); ip.ki.time = 0; ip.ki.wVk = 0; ip.ki.dwFlags = KEYEVENTF_UNICODE; ip.ki.dwExtraInfo = 0; SendInput(1, &ip, sizeof(INPUT)); } void WindowsKeyClickEmulator::_releaseKey(WORD key) { QChar symbol; if( oddIndex % 2) { symbol = 'f'; } else { symbol = 'm'; } INPUT ip; ip.type = INPUT_KEYBOARD; ip.ki.wScan = symbol.unicode(); ip.ki.time = 0; ip.ki.wVk = 0; ip.ki.dwFlags = KEYEVENTF_UNICODE + KEYEVENTF_KEYUP; ip.ki.dwExtraInfo = 0; SendInput(1, &ip, sizeof(INPUT)); }