How to trace and log user's actions on a form ? lazarus / 21-General ---------------------------------------------------------------------- mirce.vladimirov · 2023-05-11 09:45 How can i trace user actions on a Lazarus form, to write a line that contains control's name and user's action, may looks like : Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i combobox_select_user_action;selected text="the text that was selected in this combobox";edit_phonenumber;got focus;edit_phonenumber;changed from "previous text" to "the newly typed text";button_write;got focus;button_write;clicked; Is there a way to create one single procedure or function that would be invoked always, no matter which control the user is performing action ? I need to trace how and what exactly users are doing,  but no need to catch all actions, eg. no need to trace mouse-over, mouse-enter, mouse-leave... ---------------------------------------------------------------------- howardpc · 2023-05-11 15:42 Have you tried using Application.OnUserInput with a filter to ignore mouse events? ---------------------------------------------------------------------- mirce.vladimirov · 2023-05-11 17:58 Quote from: howardpc on May 11, 2023, 05:42:24 pmHave you tried using Application.OnUserInput with a filter to ignore mouse events? No, I don't even know a thing about that, where can I read about it, or see some examples ? ---------------------------------------------------------------------- TRon · 2023-05-11 19:57 Quote from: mirce.vladimirov on May 11, 2023, 07:58:16 pmNo, I don't even know a thing about that, where can I read about it, or see some examples ? Application properties. In particular event OnUserInput. Create a new form, from the additional tab add the non visual component TPapplicationproperties to the Form. Add a memo to the form (Memo1) and other components that you wish to test with. On the object inspector select the application properties component, switch to the tab events and add the event OnUserInput. Now you have everything in place to add some code: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.ApplicationProperties1UserInput(Sender: TObject; Msg: Cardinal);var  Info: string = 'unknown';begin  case msg of    //    LM_NULL              : Info := 'LM_NULL';    LM_CREATE            : Info := 'LM_CREATE';    LM_DESTROY           : Info := 'LM_DESTROY';  LM_MOVE              : Info := 'LM_MOVE';     // keys    LM_KEYDOWN         : Info := 'LM_KEYDOWN';    LM_KEYUP             : Info := 'LM_KEYUP';    LM_CHAR              : Info := 'LM_CHAR';     LM_SYSKEYDOWN        : Info := 'LM_SYSKEYDOWN';    LM_SYSKEYUP        : Info := 'LM_SYSKEYUP';    LM_SYSCHAR           : Info := 'LM_SYSCHAR';     //    LM_COMMAND           : Info := 'LM_COMMAND';  LM_SYSCOMMAND        : Info := 'LM_SYSCOMMAND';    LM_TIMER           : Info := 'LM_TIMER';    LM_HSCROLL           : Info := 'LM_HSCROLL';    LM_VSCROLL           : Info := 'LM_VSCROLL';    LM_CTLCOLORMSGBOX    : Info := 'LM_CTLCOLORMSGBOX';    LM_CTLCOLOREDIT      : Info := 'LM_CTLCOLOREDIT';    LM_CTLCOLORLISTBOX   : Info := 'LM_CTLCOLORLISTBOX';    LM_CTLCOLORBTN       : Info := 'LM_CTLCOLORBTN';    LM_CTLCOLORDLG       : Info := 'LM_CTLCOLORDLG';    LM_CTLCOLORSCROLLBAR : Info := 'LM_CTLCOLORSCROLLBAR';    LM_CTLCOLORSTATIC    : Info := 'LM_CTLCOLORSTATIC';     // mouse    LM_MOUSEMOVE         : Info := 'LM_MOUSEMOVE';    LM_LBUTTONDOWN     : Info := 'LM_LBUTTONDOWN';    LM_LBUTTONUP         : Info := 'LM_LBUTTONUP';    LM_LBUTTONDBLCLK     : Info := 'LM_LBUTTONDBLCLK';    LM_RBUTTONDOWN       : Info := 'LM_RBUTTONDOWN';    LM_RBUTTONUP       : Info := 'LM_RBUTTONUP';    LM_RBUTTONDBLCLK     : Info := 'LM_RBUTTONDBLCLK';    LM_MBUTTONDOWN       : Info := 'LM_MBUTTONDOWN';    LM_MBUTTONUP         : Info := 'LM_MBUTTONUP';  LM_MBUTTONDBLCLK     : Info := 'LM_MBUTTONDBLCLK';    LM_MOUSEWHEEL      : Info := 'LM_MOUSEWHEEL';    LM_XBUTTONDOWN       : Info := 'LM_XBUTTONDOWN';    LM_XBUTTONUP         : Info := 'LM_XBUTTONUP';  LM_XBUTTONDBLCLK     : Info := 'LM_XBUTTONDBLCLK';    LM_MOUSEHWHEEL     : Info := 'LM_MOUSEHWHEEL';     LM_PARENTNOTIFY      : Info := 'LM_PARENTNOTIFY';    LM_CAPTURECHANGED    : Info := 'LM_CAPTURECHANGED';    LM_DROPFILES         : Info := 'LM_DROPFILES';     LM_SELCHANGE         : Info := 'LM_SELCHANGE';    LM_DPICHANGED        : Info := 'LM_DPICHANGED';    LM_CUT             : Info := 'LM_CUT';    LM_COPY              : Info := 'LM_COPY';    LM_PASTE             : Info := 'LM_PASTE';    LM_CLEAR             : Info := 'LM_CLEAR';     // control notifications    CN_KEYDOWN        : Info := 'CN_KEYDOWN';    CN_KEYUP            : Info := 'CN_KEYUP';    CN_CHAR             : Info := 'CN_CHAR';    CN_SYSKEYUP         : Info := 'CN_SYSKEYUP';    CN_SYSKEYDOWN       : Info := 'CN_SYSKEYDOWN';    CN_SYSCHAR          : Info := 'CN_SYSCHAR';    CN_NOTIFY           : Info := 'CN_NOTIFY';  end;   if msg <> LM_MOUSEMOVE then  begin    Memo1.Append(Format('Control = %s, message = %s (%d) ', [Sender.ClassName, info, msg]));    {$ifdef LCLGTK2}    Memo1.SelStart:=Length(Memo1.Lines.Text)-1;    Memo1.SelLength:=0;    {$endif}  end;end; Build the application, run it and do some stuff to your form's components to see what is happening. As you can see, it is very rudimentary messaging that you receive. You would need to add specific handling for each of your used components. You have access to the component and you know which action was taken. For example in an edit box the mousebutton is pressed (button down) to select some text (no event) and it was released (buttonup). Now you can check in your edit box's properties if the selection was changed. Same goes for all other things that you would like to check: which means a lot of work if you want something like you asked for. I wonder if it would not be easier to add the events to the components themselves and act on it, e.g. I do not know if some things could be implemented in a generic manner for example for all the edit boxes, or buttons etc. edit: I forgot to mention that in order to be able to make use of the constants you need to add the unit lmessages to your use clause.