03-16-2024, 06:50 AM
//add this function in file "Mouse triggers". Or add its code to another function in that file.
[Triggers]
void Example_mouse_trigger_with_FilterOf_and_menu() {
//Triggers.Of.Window(cn: "Notepad*"); //optional here, because the Triggers.FuncOf function does the same
wnd childWindow = default; //we use this variable to pass the child window handle to the trigger action
Triggers.FuncOf.NextTrigger = o => { //like a QM filter function. https://www.libreautomate.com/api/Au.Triggers.TriggerFuncs.html
var mta = o as MouseTriggerArgs;
if (mta.Window.ClassNameIs("Notepad*")) {
childWindow = wnd.fromMouse(WXYFlags.NeedControl);
if (childWindow.ClassNameIs("Scintilla")) return true;
}
return false;
};
Triggers.Mouse[TMClick.Right, flags: TMFlags.ButtonModUp] = o => { script.run(@"Example_mouse_trigger_with_FilterOf_and_menu.cs", $"{childWindow.Handle}"); };
//Triggers.Of.AllWindows();
}// script "Example_mouse_trigger_with_FilterOf_and_menu.cs"
var childWindow = (wnd)args[0].ToInt();
childWindow.Focus();
var m = new popupMenu("f2dde795-cd80-4ee3-982a-67a95d3abbf5");
if (0 == childWindow.Send(2650)) { //SCI_GETSELECTIONEMPTY. https://github.com/qgindi/LibreAutomate/blob/master/Au.Controls/KScintilla/Sci%20API.cs
m["S_test1"] = o => { print.it(o); };
m.Separator(); //LA menus can have only horizontal separators
m.Submenu("S_test2", m => {
m["S_test21"] = o => { print.it(o); };
});
} else {
m["E_test1"] = o => { print.it(o); };
m.Separator(); //LA menus can have only horizontal separators
m.Submenu("E_test2", m => {
m["E_test21"] = o => { print.it(o); };
});
}
m.Show();