| 189 | }; |
| 190 | |
| 191 | void PressKeys(const std::vector<HotkeyType> &keys, int duration) |
| 192 | { |
| 193 | if (!canSimulateKeyPresses) { |
| 194 | return; |
| 195 | } |
| 196 | |
| 197 | Display *display = disp(); |
| 198 | if (!display) { |
| 199 | return; |
| 200 | } |
| 201 | |
| 202 | // Press keys |
| 203 | for (auto &key : keys) { |
| 204 | auto it = keyTable.find(key); |
| 205 | if (it == keyTable.end()) { |
| 206 | continue; |
| 207 | } |
| 208 | pressFunc(display, XKeysymToKeycode(display, it->second), true, |
| 209 | CurrentTime); |
| 210 | } |
| 211 | XFlush(display); |
| 212 | |
| 213 | std::this_thread::sleep_for(std::chrono::milliseconds(duration)); |
| 214 | |
| 215 | // Release keys |
| 216 | for (auto &key : keys) { |
| 217 | auto it = keyTable.find(key); |
| 218 | if (it == keyTable.end()) { |
| 219 | continue; |
| 220 | } |
| 221 | pressFunc(display, XKeysymToKeycode(display, it->second), false, |
| 222 | CurrentTime); |
| 223 | } |
| 224 | |
| 225 | XFlush(display); |
| 226 | } |
| 227 | |
| 228 | } // namespace advss |
no test coverage detected