views:

916

answers:

2

I want to send WM_HOTKEY to be captured by other application using a global desktop HotShortCut.

The expected Keys are CTRL + F10

This is the only way I found to trigger the capture of WM_HOTKEY:

procedure TfmMain.ButtonTalkClick(Sender: TObject);
var
  Article: TArticleBase;
  Msg: TMessage;
begin
  Article:= GetSelectedArticle;
  if Article <> nil then
  begin
    Clipboard.AsText:= Article.SelectedText;
    Msg.LParamLo:= MOD_CONTROL;
    Msg.LParamHi:= VK_CONTROL or VK_F10;
    PostMessage(HWND_BROADCAST, WM_HOTKEY, 0, Msg.LParam);
  end;
end;

if I change any of the values of Msg.LParamLo or Msg.LParamHi, WM_HOTKEY is not triggered by the other app. But using this way, before the message WM_HOTKEY is captured by the Method:

procedure ManageHotKeyMsg(var Msg: TMessage); message WM_HOTKEY;

The "Windows Execute Dialog" is executed (shortcut "Windows Key" + R)

How is the right way to pass Msg.LParamLo and Msg.LParamHi, to make sure Im sending WM_HOTKEY + "CTRL + F10".

A: 

Raymond says You're Doing It Wrong:

http://blogs.msdn.com/oldnewthing/archive/2005/05/30/423202.aspx

Why don't you just talk to the other app directly using some sort of standard IPC mechanism?

Paul Betts
Tnx Paul.I dont have other app sources. Thats why I should send the keys.Ill try use SendInput.
Cesar Romero
+2  A: 

Done using PostKeyEx32.

procedure TfmMain.ButtonTalkClick(Sender: TObject);
var
  Article: TArticleBase;
begin
  Article:= GetSelectedArticle;
  if Article <> nil then
  begin
    Clipboard.AsText:= Article.SelectedText;
    PostKeyEx32(VK_F10, [ssCtrl], False);
  end;
end;

Now my Xananews build can speech :D

Cesar Romero