Home > Back-end >  How to use ASCII operate computers?
How to use ASCII operate computers?

Time:10-14

Make up a small program, for example: enter the ASCII f5, interface will be constantly refreshed, this can be achieved? How do you achieve? Please detailed guidance, thank you!!!!!

CodePudding user response:

Why have interface input ASCII?
Write directly in OnKeyPress, OnKeyDown, OnKeyUp inside not line?

CodePudding user response:

To interface constantly refreshed, the simplest a Timer, and set the input interval..
As long as the input of F5 ASCII refresh interface,
//- continuously determine whether input F5 ASCII -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
Void __fastcall TForm1: : Timer1Timer (TObject * Sender)
{
If (Edit1 - & gt; Text=="116"),//or 0 x74 or VK_F5
{
Form1 - & gt; The Refresh ();
}
}
//- focus on the Edit, judgment, press F5 to refresh only -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Void __fastcall TForm1: : Edit1KeyDown (TObject * Sender, WORD & amp; The Key,
TShiftState Shift)
{
If (Key==VK_F5)//or 116, or 0 x74
{
Form1 - & gt; The Refresh ();
}
}


CodePudding user response:

There are basically two better ways, one is a registered global hotkeys, one kind is to use the Timer:

for(int i=0; i<=256; I++) {
If (GetAsyncKeyState (I)==- 32767) {
If (I==116) {
ShowMessage (" F5 key is pressed the ");
return;
}
}
}

CodePudding user response:

Use the Timer control has a defect, is the timing of the Timer to short and may miss a key, and there's a way in program free check button

Use the Timer code is as follows:
 void __fastcall TForm1: : Timer1Timer (TObject * Sender) 
{
for(int i=0; i<=256; I++) {
If (GetAsyncKeyState (I)==- 32767) {
If (I==116) {
ShowMessage (L "F5 key is pressed the");
//break;//end of the cycle
return;
}
}
}
}

CodePudding user response:

 void __fastcall TForm1: : Timer1Timer (TObject * Sender) 
{
for(int i=0; i<=256; I++) {
If (GetAsyncKeyState (I)==- 32767) {
If (I==116) {
//ShowMessage (L "F5 key is pressed the");
//break;//end of the cycle
The Refresh ();//refresh
return;
}
}
}
}
  • Related