按键模仿鼠标
假设一个对话框,上面只有一个按钮.
我若不用鼠标点.能不能点Y键.达到和用鼠标点一样的效果.包括按钮被按下去的样子.
问题点数:50、回复次数:6Top
1 楼vcmute(BCare4 H1Rest Good9!)回复于 2006-03-18 18:18:16 得分 10
SendInput
mouse_eventTop
2 楼du51(郁郁思扬)回复于 2006-03-18 18:19:45 得分 0
首先谢谢楼上的.你能不能讲详细点..
我的意思就是说,点鼠标在上面和点Y完全是一样的效果.
Top
3 楼du51(郁郁思扬)回复于 2006-03-18 19:11:36 得分 0
帮帮忙呀.顶.Top
4 楼iswjh(哪天我才会Turbo C)回复于 2006-03-18 20:10:50 得分 10
请看SDK文档:
The SendInput function synthesizes keystrokes, mouse motions, and button clicks.
Syntax
UINT SendInput(UINT nInputs,
LPINPUT pInputs,
int cbSize
);
Parameters
nInputs
[in] Specifies the number of structures in the pInputs array.
pInputs
[in] Pointer to an array of INPUT structures. Each structure represents an event to be inserted into the keyboard or mouse input stream.
cbSize
[in] Specifies the size, in bytes, of an INPUT structure. If cbSize is not the size of an INPUT structure, the function will fail.
Return Value
The function returns the number of events that it successfully inserted into the keyboard or mouse input stream. If the function returns zero, the input was already blocked by another thread.
To get extended error information, call GetLastError.
Remarks
The SendInput function inserts the events in the INPUT structures serially into the keyboard or mouse input stream. These events aren't interspersed with other keyboard or mouse input events inserted either by the user (with the keyboard or mouse) or by calls to keybd_event, mouse_event, or other calls to SendInput.
This function does not reset the keyboard's current state. Any keys that are already pressed when the function is called might interfere with the events that this function generates. To avoid this problem, check the keyboard's state with the GetAsyncKeyState function and correct as necessary.
Top
5 楼Mackz(在相互)回复于 2006-03-18 20:15:37 得分 15
按钮的Caption设置为"是(&Y)"Top
6 楼huaboy408(Thinking...)回复于 2006-03-18 20:16:25 得分 15
用PreTranslateMessage,截获Y键消息,然后用mouse_event模拟鼠标事件Top




