Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Context Menu Trigger
#3
Thanks for your help!
This approach is truly elegant and doesn’t require modifying the shell menu.

 How can the following code be made compatible with selecting the folders on the desktop?
 
Code:
Copy      Help
// class "Window triggers.cs"
using Au.Triggers;

partial class Program
{
    [
Triggers]
    void WindowTriggers()
    {

        Triggers.Options.ThreadNew();
        
        if (true)
        {

            Triggers.Window[TWEvent.Visible, "", "#32768", "explorer.exe"] = t =>
            {
                if (wnd.findAll("", "#32768", "explorer.exe").Length > 1) return; //submenu
                
                var m = new popupMenu("d914e490-6ce6-4319-b979-cf0de0322f43");
                
                var wExplorer = wnd.active;
                if (ExplorerFolder.Of(wExplorer) is { } e && e.GetSelectedItems() is { Length: 2 } sel && filesystem.exists(sel[0]).Directory && filesystem.exists(sel[1]).Directory)
                {

                    m["2 folders"] = o =>
                    {
                        keys.send("Esc"); //close the Explorer's menu
                        script.run("2 folders", sel[0], sel[1]);
                    };
                }

                
                if (!m.Items.Any()) return;
                
                var wMenu = t.Window;
                m.Show(PMFlags.AlignRight, excludeRect: wMenu.Rect, owner: wMenu);
            };
        }
        
    }
}


How can the menu be displayed as close as possible to the mouse cursor (next to the original right-click menu)?
In many cases, the new menu appears on the left side of the original right-click menu, far away from the mouse cursor and requiring extra mouse movement, as shown in the image below.
https://i.ibb.co/TxDVS3G6/pic.png


Messages In This Thread
Context Menu Trigger - by Davider - 01-17-2026, 12:39 PM
RE: Context Menu Trigger - by Gintaras - 01-17-2026, 03:56 PM
RE: Context Menu Trigger - by Davider - 01-17-2026, 10:10 PM
RE: Context Menu Trigger - by Gintaras - 01-18-2026, 06:00 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)