| 53 | } |
| 54 | |
| 55 | void KeyboardCode::SendKey() { |
| 56 | #if defined(__WXGTK__) |
| 57 | KeyCode k= XKeysymToKeycode((Display *) wxGetDisplay(), (KeySym) m_nativeKeyCode); |
| 58 | XTestFakeKeyEvent((Display *) wxGetDisplay(), k, true, 0); |
| 59 | XTestFakeKeyEvent((Display *) wxGetDisplay(), k, false, 0); |
| 60 | #else |
| 61 | // It seems that, to work properly, SendInput() need both the virtual-key |
| 62 | // code and the scan code. Note that KEYEVENTF_EXTENDEDKEY flag is not used. |
| 63 | UINT scanCode = ::MapVirtualKey(m_nativeKeyCode, MAPVK_VK_TO_VSC); |
| 64 | |
| 65 | INPUT ip; |
| 66 | memset(&ip, 0, sizeof(ip)); |
| 67 | ip.type= INPUT_KEYBOARD; |
| 68 | ip.ki.wVk= m_nativeKeyCode; |
| 69 | ip.ki.wScan= (WORD) scanCode; |
| 70 | |
| 71 | // Key press |
| 72 | SendInput(1, &ip, sizeof(ip)); |
| 73 | |
| 74 | // Key release |
| 75 | ip.ki.dwFlags|= KEYEVENTF_KEYUP; |
| 76 | SendInput(1, &ip, sizeof(ip)); |
| 77 | #endif |
| 78 | } |
| 79 | |
| 80 | KeyboardCode KeyboardCode::ReadKeyCode() { |
| 81 | #if defined(__WXGTK__) |