Announcement

Collapse
No announcement yet.

Capture Function Key Press in OnCtrlMessage?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Capture Function Key Press in OnCtrlMessage?

    Is there a way of generating an event in the OnCtrlMessage action of a screen when a Ctrl key is pressed (for example F1)? I am using Setup Factory 9.2.

    Alternatively, is there a way of firing the OnHelp screen action when the F1 key is pressed?

    There does not appear to be a way, but I was hoping someone knew of a neat trick.

    Thanks.

  • #2
    You could start a timer in the On Preload event of your screen, making it fire every 200 ms. When this happens, execute the GetKeyState function of User32.dll to see if the key you want to monitor is currently pressed. If it is, run your script. Example:

    On Preload event script
    Code:
    Debug.ShowWindow();
    Screen.StartTimer(200);
    On Ctrl Message event script
    Code:
    if (e_MsgID == MSGID_ONTIMER) then
       local nKeyState = DLL.CallFunction(_SystemFolder.."\\user32.dll", "GetKeyState", "112", DLL_RETURN_TYPE_INTEGER, DLL_CALL_STDCALL);
       if (String.ToNumber(nKeyState) < 0) then
          Debug.Print("F1 pressed...\r\n");
       end
    end
    Ulrich
    Last edited by Ulrich; 11-13-2021, 03:40 AM. Reason: Code correction

    Comment


    • #3
      Thanks! Very creative solution.

      Comment

      Working...
      X