Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Triggers, event log viewer
#6
Use class `WinEventHook`.

If you want to use it in the `@Triggers and toolbars` process (together with your keyboard/mouse/autotext/window triggers), a good place for the code is file `Other triggers`, or a file like it in the same folder. To open or create-open the file, click menu `TT > Other triggers`.

Example. A function in file `Other triggers`.
 
Code:
Copy      Help
    //this function runs at startup, and sets one or more UI element event hooks
    [Triggers]
    void WinEventTriggers() {
        var hook = new WinEventHook(EEvent.SYSTEM_FOREGROUND, 0, x => {
            //this code runs when an UI object event occurs (in this case - a window activated)
            print.it(x.event_, x.w);
            //var e = x.GetElm();
            //print.it(e);

        });
        
        //example for multiple events
        var hook2 = new WinEventHook([EEvent.SYSTEM_MINIMIZESTART, EEvent.SYSTEM_MINIMIZEEND], x => {
            print.it(x.event_, x.w);
            //var e = x.GetElm();
            //print.it(e);

        });
        
    }

This can be useful to discover events. Run as a separate script.
Code:
Copy      Help
// script "Log UI element events.cs"
print.clear();

var wLa = wnd.find(0, "LibreAutomate", "HwndWrapper[Au.Editor;*");
var wLaOutput = wLa.Child(0, "Output_text", "Scintilla");
int i = 0;
using var hook = new WinEventHook(EEvent.MIN, EEvent.MAX, x => {
    //skip some unwanted events
    if (x.w == wLaOutput) return;
    if (x.idObject == EObjid.CURSOR) return;
    //if (x.event_ == EEvent.OBJECT_LOCATIONCHANGER) return; //example - skip an event type
    
    print.it(++i, x.event_, x.w);
    //var e = x.GetElm();
    //print.it(e);

}, flags: EHookFlags.SKIPOWNPROCESS);
dialog.show("Logging UI element events", "Close me to stop.");
 
[/code]


Messages In This Thread
Triggers, event log viewer - by cuitino - 08-08-2024, 05:34 PM
RE: Triggers, event log viewer - by Gintaras - 08-08-2024, 06:02 PM
RE: Triggers, event log viewer - by cuitino - 07-08-2025, 04:46 PM
RE: Triggers, event log viewer - by Gintaras - 07-08-2025, 06:04 PM
RE: Triggers, event log viewer - by cuitino - 03-16-2026, 06:55 PM
RE: Triggers, event log viewer - by Gintaras - 03-16-2026, 07:39 PM
RE: Triggers, event log viewer - by cuitino - 03-16-2026, 07:56 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)