void __fastcall TForm1::Edit2KeyDown(TObject *Sender, WORD &Key, TShiftState Shift) if (Shift.Contains(ssAlt) && Shift.Contains(ssCtrl)) 

How to change Alt to A / F key code? Using the key code ( 65 ) does not help.

  • Type the Key variable and you will know the codes for all the keys you need - Alexus
  • GetAsyncKeyState tried? - Duracell
  • @duracell No, I have not tried it - aaa
  • @alexus 65, I wrote that I prescribed 65 in the condition and did not work - aaa
  • @ Eugene, added the code in the answer, that is not clear, ask. - Duracell

2 answers 2

 if ((Shift.Contains(ssCtrl)) && (Key == 65)) 
     #include <Windows.h> #include <iostream> using namespace std; bool keydown(int key) { return (GetAsyncKeyState(key) & 0x8000) != 0; } int main() { while (!keydown(VK_ESCAPE)) { if (keydown(VK_LCONTROL) && keydown('A')) { cout << "combo pressed!" << endl; } Sleep(10); } return 0; } 
    • Will the program work if I have a Russian layout? Have you seen that this is not a console application? See my answer - aaa
    • It will work with any layout and the fact that I gave an example of a console application does not mean that it will not work in "forms", the main thing is to tear out the function from the example and put it on the event you need or on the "timer". - Duracell