Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Context menu in specific window
#2
Code:
Copy      Help
    //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();
    }

Code:
Copy      Help
// 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();


Messages In This Thread
Context menu in specific window - by Davider - 03-14-2024, 11:01 PM
RE: Context menu in specific window - by Gintaras - 03-16-2024, 06:50 AM
RE: Context menu in specific window - by Gintaras - 03-16-2024, 07:08 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)