hidrau
asked on
trigger a hotkey through button
Hello guys,
I need a way to trigger a hotkey = Ctrl + F12
when I click on a button it must trigger this hotkey, how can I do this?
Thanks
I need a way to trigger a hotkey = Ctrl + F12
when I click on a button it must trigger this hotkey, how can I do this?
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
sorry last one i didn't test. that is not working for me
procedure TForm2.Button1Click(Sender : TObject);
begin
keybd_event(VK_CONTROL,0 ,0, 0) ;
keybd_event(VK_F5,0 ,0, 0) ;
keybd_event(VK_F5,0 ,KEYEVENTF_KEYUP, 0) ;
keybd_event(VK_CONTROL,0 ,KEYEVENTF_KEYUP, 0) ;
end;
begin
keybd_event(VK_CONTROL,0 ,0, 0) ;
keybd_event(VK_F5,0 ,0, 0) ;
keybd_event(VK_F5,0 ,KEYEVENTF_KEYUP, 0) ;
keybd_event(VK_CONTROL,0 ,KEYEVENTF_KEYUP, 0) ;
end;
from the help of keyb_event: Windows NT/2000/XP:This function has been superseded. Use SendInput instead.
Are you sending this key to your own app or to another application?
ASKER
to my own application and not to another application
my solution should work for both local and global hotkeys
If same application then why can't you call the event directly.
eg: Form1.Menu1.click;
eg: Form1.Menu1.click;
Ye was gona say rather just call that button that was assigned to the alt-f12
begin
SendMessageA(Form1.Handle,
SendMessageA(Form1.Handle,
SendMessageA(Form1.Handle,
SendMessageA(Form1.Handle,
end;