Is there any tool that can do this? Just like a website and for the same basic reasons?
UPDATE --- I mean collecting statistics info about an application that I am writing I need to know what options are used most, when, times, etc.
I've done something like this in the past.
There are two ways that I can think of to do this.
With Actions:
When using actions it's very easy to follow the UI usage by placing code in the TActionList.OnExecute handler. This event fires off before the individual action executes which allows for you to trace what has happened and when.
For Example:
procedure TForm1.ActionList1Execute(Action: TBasicAction; var Handled: Boolean);
begin
WriteToLog(TAction(TBasicAction).Caption);
end;
Without Actions:
If your not using Actions it becomes a little more difficult but not impossible. You create have to create a new unit with a TMenuItem descendant with your logging code in it. Make sure to place your new unit after the MENU unit in the uses clause in every unit that makes use of it. The new descendant has to be called TMenuItem for this to work. Since your essentially reintroducing the same class but with extended functionality.
Here is a quick unit I threw together showing a very simple example.
unit MenuItemLogger;
interface
uses Menus;
Type
TMenuItem = class(Menus.TMenuItem)
public
procedure Click; override;
end;
implementation
uses windows;
{ TMenuItem }
procedure TMenuItem.Click;
begin
outputdebugstring(PWideChar(self.Caption));
inherited;
end;
end.
To use the above unit place it as the last unit in the uses clause of any form/DataModule with menus (TMainMenu or TPopupMenu) that you want to trace. If you don't want to trace a particular unit don't include it.
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ActnList, Menus, MenuItemLogger;
These two methods are simple and while they do work they probably are not the best solutions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With