Menu ▾ ▴

#3 KEYS: send real keystrokes to a form or control

open
nobody
None
4 hours ago
4 hours ago
No

GxInspect has no way to press keys. Testing a GExperts feature that hooks Ctrl+C and Ctrl+X through the ToolsAPI's keyboard bindings needed real key presses, because such a binding only fires on keys that go through the IDE's own key handling; calling code or posting WM_KEYDOWN does not test that path. The tests used a PowerShell script with keybd_event instead.

Proposed syntax: KEYS <form-id> [<control-name>] <keys>, with keys written the way TextToShortCut reads them (Ctrl+C, Ctrl+Shift+F5, Esc) and several separated by spaces. It brings the form to the front and focuses the control (the edit control for an editor window) before pressing them.

Traps found while doing it by hand:

  • Windows only lets a process take the foreground under conditions. The usual trick of tapping Alt first puts the target's menu bar into keyboard mode, and then every second key goes to the menu instead of the editor. Tapping an unused key (VK_F24) worked. The server runs inside the IDE, so it may be able to bring its own window to the front without any trick.
  • Sending Esc to leave menu mode cancels a modal dialog that happens to be open.
  • In Delphi 6 and 7 the editor is a window of its own (TEditWindow), not part of TAppBuilder.
  • Real input goes to whatever window has the focus when it arrives, so the command must check the foreground window right before pressing and refuse if it changed. Keys typed by the user at the same time get mixed in.

The answer should say which window had the focus when the keys were sent.

Discussion


Log in to post a comment.