Home > Software engineering >  Virtual keyboard keys
Virtual keyboard keys

Time:11-21

I now use keybd_event to send keys

Press the number keys, for example, "3"

Define a timer
The SetTimer (1500, NULL);


Implementation in the OnTimer function press the number keys "3" :

Keybd_event (51,0,0,0);//3
Keybd_event (KEYEVENTF_KEYUP 51, 0, 0);

Then I found "3" will keep is pressed (in notepad will continue to enter 3)

Consult how to implement in a regular cycle only press a number "3"???????

CodePudding user response:

KillTimer OnTimer function first

CodePudding user response:

 
Void CDlg1Dlg: : OnTimer (UINT nIDEvent)
{
BYTE vKey='3';
BYTE vSca=MapVirtualKey (vKey, 0);
Keybd_event (vKey vSca, 0, 0);
Keybd_event (vKey, vSca, KEYEVENTF_KEYUP, 0);

}


  • Related