Страница: 1 |
Послать ему WM_KEYDOWN, WM_KEYUP Подскажи, пожалуйста, как правильно послать сообщение WM_KEYDOWN & WM_KEYUP для клавиши ENTER, если можно подробнее остановись на первом пораметре сообщений. Вообще для того чтобы послать сообщение используют SendMessage/PostMessage, ыот только проблемма, я пытался так отсылать - не получается А нельзя с помощью обычных VB команд: Активируешь окно с помощью App.Activate (Это по-моему попроще, чем через hWnd и командой SendMessage отправляещь: {ENTER} Я из PB-DLL'ки посылал VB-окну сообщение так: SendMessage hWnd, %WM_KEYDOWN, wParam, lParam ,где wParam - ASCCII код клавиши; lParam точно не помню что, но 24 бит в нём указывает является ли клавиша расширенной (Шифт, Контрал, Хоме, Энд и т.д.) Если 1 - да, 0 - нет (см. MSDN). The WM_KEYDOWN message is posted to the window with the keyboard focus when a nonsystem key is pressed. A nonsystem key is a key that is pressed when the ALT key is not pressed. WM_KEYDOWN nVirtKey = (int) wParam; // virtual-key code lKeyData = lParam; // key data Parameters nVirtKey Value of wParam. Specifies the virtual-key code of the nonsystem key. lKeyData Value of lParam. Specifies the repeat count, scan code, extended-key flag, context code, previous key-state flag, and transition-state flag, as shown in the following table: Value Description 0-15 Specifies the repeat count. The value is the number of times the keystroke is repeated as a result of the user holding down the key. 16-23 Specifies the scan code. The value depends on the original equipment manufacturer (OEM). 24 Specifies whether the key is an extended key, such as the right-hand ALT and CTRL keys that appear on an enhanced 101- or 102-key keyboard. The value is 1 if it is an extended key; otherwise, it is 0. 25-28 Reserved; do not use. 29 Specifies the context code. The value is always 0 for a WM_KEYDOWN message. 30 Specifies the previous key state. The value is 1 if the key is down before the message is sent, or it is 0 if the key is up. 31 Specifies the transition state. The value is always 0 for a WM_KEYDOWN message. Return Values An application should return zero if it processes this message. Default Action If the F10 key is pressed, the DefWindowProc function sets an internal flag. When DefWindowProc receives the WM_KEYUP message, the function checks whether the internal flag is set and, if so, sends a WM_SYSCOMMAND message to the top-level window. The wParam parameter of the message is set to SC_KEYMENU. Remarks Because of the autorepeat feature, more than one WM_KEYDOWN message may be posted before a WM_KEYUP message is posted. The previous key state (bit 30) can be used to determine whether the WM_KEYDOWN message indicates the first down transition or a repeated down transition. For enhanced 101- and 102-key keyboards, extended keys are the right ALT and CTRL keys on the main section of the keyboard; the INS, DEL, HOME, END, PAGE UP, PAGE DOWN and arrow keys in the clusters to the left of the numeric keypad; and the divide (/) and ENTER keys in the numeric keypad. Other keyboards may support the extended-key bit in the lKeyData parameter. SendKeys "{ENTER}" А лучше (быстрее) : sendkeys "~" Страница: 1 |
Вопрос: Эмуляция нажатия клавиши "ENTER"
Добавлено: 07.04.04 09:39
Автор вопроса:
mayevskyy | ICQ: 1234567890
Как выполнить эмуляцию нажатия клавиши "ENTER" окна Windows зная его hwnd?
Ответы
Всего ответов: 8
Номер ответа: 1
Автор ответа: Sharp
Лидер форума
ICQ: 216865379
Вопросов: 106
Ответов: 9979
Web-сайт:
Профиль | | #1
Добавлено: 07.04.04 10:42
Номер ответа: 2
Автор ответа: mayevskyy
ICQ: 1234567890
Вопросов: 7
Ответов: 4
Профиль | | #2
Добавлено: 07.04.04 15:15
Номер ответа: 3
Автор ответа: sne
Разработчик Offline Client
ICQ: 233286456
Вопросов: 34
Ответов: 5445
Web-сайт:
Профиль | | #3
Добавлено: 07.04.04 17:09
Вернее получается, но не всегда корректно... Пришлось остановиться на кривом способе, а именно, ставить требуемое окно как активное, а далее через keyb_events отсылать нажатую клавишу...
Номер ответа: 4
Автор ответа: Vilya
ICQ: 232995216
Вопросов: 12
Ответов: 63
Web-сайт:
Профиль | | #4
Добавлено: 07.04.04 17:11
Номер ответа: 5
Автор ответа: @CyRax PTR
ICQ: 204447456
Вопросов: 28
Ответов: 664
Web-сайт:
Профиль | | #5
Добавлено: 08.04.04 00:56
Номер ответа: 6
Автор ответа: Sharp
Лидер форума
ICQ: 216865379
Вопросов: 106
Ответов: 9979
Web-сайт:
Профиль | | #6
Добавлено: 10.04.04 18:02
Номер ответа: 7
Автор ответа: M@X
Вопросов: 38
Ответов: 43
Профиль | | #7
Добавлено: 10.04.04 21:04
Номер ответа: 8
Автор ответа: Morpheus
Вопросов: 224
Ответов: 3777
Web-сайт:
Профиль | | #8
Добавлено: 11.04.04 06:29