| 3 | QiMouseTrack mouseTrack; |
| 4 | clock_t mouseTrack_prev = 0; |
| 5 | void RecordInput(BYTE vk, bool state, POINT pt) |
| 6 | { |
| 7 | if (Input::isMouse(vk) && InRect(Window::rect((HWND)Qi::widget.record->winId()), Input::pos())) return; |
| 8 | if (Qi::recordWindow && !IsWindowVisible(Qi::recordWindow)) |
| 9 | { |
| 10 | Qi::widget.recordClose(); |
| 11 | Qi::popText->Popup(2000, "窗口已失效", RGB(255, 64, 64)); |
| 12 | } |
| 13 | |
| 14 | if (vk) |
| 15 | { |
| 16 | // delay |
| 17 | if (Qi::recordClock) |
| 18 | { |
| 19 | clock_t nowClock = clock(); |
| 20 | if (mouseTrack.s.empty()) |
| 21 | { |
| 22 | QiDelay delay; |
| 23 | delay.max = delay.min = nowClock - Qi::recordClock; |
| 24 | Qi::record.append(std::move(delay)); |
| 25 | } |
| 26 | else |
| 27 | { |
| 28 | Qi::record.append(std::move(mouseTrack)); |
| 29 | mouseTrack.reset(); |
| 30 | } |
| 31 | Qi::recordClock = nowClock; |
| 32 | } |
| 33 | else |
| 34 | { |
| 35 | Qi::recordClock = clock(); |
| 36 | mouseTrack.reset(); |
| 37 | } |
| 38 | // mouse |
| 39 | if (Input::isMouse(vk)) |
| 40 | { |
| 41 | QiMouse mouse; |
| 42 | POINT position; |
| 43 | if (Qi::recordWindow) |
| 44 | { |
| 45 | POINT wpt = Window::pos(Qi::recordWindow); |
| 46 | position = QiCvt::WP_RtA({ pt.x - wpt.x, pt.y - wpt.y }, Qi::recordWindow); |
| 47 | } |
| 48 | else |
| 49 | { |
| 50 | position = QiCvt::SP_RtA(pt); |
| 51 | } |
| 52 | mouse.x = position.x; |
| 53 | mouse.y = position.y; |
| 54 | Qi::record.append(std::move(mouse)); |
| 55 | } |
| 56 | // key |
| 57 | { |
| 58 | QiKey key; |
| 59 | key.vk = vk; |
| 60 | if (state) key.state = QiKey::down; |
| 61 | else key.state = QiKey::up; |
| 62 | Qi::record.append(std::move(key)); |