Hi,
trying to send simple keystrokes to X-Plane 11 but it is not working.
I am able to send them to notepad but X-Plane does not work, it just ignores them.
procedure TForm1.Button5Click(Sender: TObject);
var XplaneWindowHWND : HWND;
begin
XplaneWindowHWND := findwindow('notepad',nil); // This works
//XplaneWindowHWND := findwindow('X-System',nil); // this "works"
if (XplaneWindowHWND <> 0) then
begin
XplaneWindowHWND := FindWindowEx(XplaneWindowHWND, FindWindow('Edit', nil), nil, nil); // this works
//XplaneWindowHWND := FindWindowEx(XplaneWindowHWND, FindWindow('X-System', nil), nil, nil); // this doesn't, not sure what to specify for FindWindo
SendMessage(XplaneWindowHWND, WM_CHAR, word('g'), 0);
Memo1.Lines.Add('Focused and sent char')
end
else
Memo1.Lines.Add('Failed to find the window')
end;
The example using notepad looks for a window(child window?) named "Edit", X-plane does not have any child window so I don't know how/if to use findwindow.
Now, a simple autohotkey is able to send the keypress 'g' without any problem (using CTRL+J for example):
^j::
Send, g
return
So it is possible. What prevents me to send the keystrokes to the simulator?
I have tried KeyInput.Press but nothing, it works only for notepad
TIA
Giuseppe Marullo
Lazarus 2.0.6 / FPC 3.0.4