/////////////////////////////////////////////////////////////////////////////// // Selects the entire current line and converts it to the current keyboard layout void SwitchAndConvert(void*) { SendKeyCombo(VK_CONTROL, 'A', TRUE); HKL sourceLayout = GetCurrentLayout(); HKL targetLayout = SwitchLayout(); ConvertSelectedTextInActiveWindow(sourceLayout, targetLayout); }
/////////////////////////////////////////////////////////////////////////////// // A LowLevelHookProc implementation that captures the CapsLock key LRESULT CALLBACK LowLevelHookProc(int nCode, WPARAM wParam, LPARAM lParam) { if(nCode < 0) return CallNextHookEx(g_hHook, nCode, wParam, lParam); KBDLLHOOKSTRUCT* data = (KBDLLHOOKSTRUCT*)lParam; BOOL caps = data->vkCode == VK_CAPITAL && wParam == WM_KEYDOWN; // ignore injected keystrokes if(caps && (data->flags & LLKHF_INJECTED) == 0) { BOOL ctrl = GetKeyState(VK_CONTROL) < 0; // Handle CapsLock - only switch current layout if(!ctrl) { SwitchLayout(); return 1; } // Handle Ctrl-CapsLock - switch current layout and convert text in current field else { // We start SwitchLayoutAndConvertSelected in another thread since it simulates // keystrokes to copy and paste the text which call back into this hook. // That isn't good.. _beginthread(SwitchAndConvert, 0, NULL); return 1; // prevent windows from handling the keystroke } } return CallNextHookEx(g_hHook, nCode, wParam, lParam); }
VirtualKeyboardQt::VirtualKeyboardQt(MythMainWindow *parent, QWidget *parentEdit, const char *name, bool setsize) : MythThemedDialog(parent, name, setsize) { setFrameStyle(QFrame::Panel | QFrame::Raised); setLineWidth(1); m_parentEdit = parentEdit; SwitchLayout(gCoreContext->GetLanguage()); }
INT_PTR ServiceSwitch(WPARAM wParam, LPARAM lParam) { SwitchLayout(lParam); return 0; }