always popup submenus on right side of window Topic is solved

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
sanneedshelp
Posts: 18
Joined: 10 Mar 2024, 19:52

always popup submenus on right side of window

Post by sanneedshelp » 24 Mar 2024, 17:37

Hi , wanted to know if its possible to always populate the submenu to the right of the window and auto adjust its length ? i don't want to define coordinates as each person can have there own resolution and monitor size

Code: Select all


m    := Menu()
mainmenu :=  Menu()
submenu1 :=  Menu()
submenu2 :=  Menu()


m.Add("urls", mainmenu)
mainmenu.Add("url1", submenu1)
submenu1.Add("This should always populate on the Right Regardless where i open and adjust it itself without setting coordinates", MenuHandler1)

mainmenu.Add("url2", submenu2)
submenu2.Add("https://www.autohotkey.com/", MenuHandler1)



MenuHandler1(item, *) {
    Run item
}

#z::m.Show
DllCall("SystemParametersInfo", "uint", 0x001C, "uint", 1, "int", 0, "uint", 0)



i followed this post but it did not work viewtopic.php?style=7&t=95327



Like this even if i open to the corner of the window
image.png
image.png (40.58 KiB) Viewed 97 times
instead of
image.png
image.png (47.68 KiB) Viewed 97 times

User avatar
RaptorX
Posts: 388
Joined: 06 Dec 2014, 14:27
Contact:

Re: always popup submenus on right side of window  Topic is solved

Post by RaptorX » 26 Mar 2024, 08:16

I do not think it is possible under certain conditions. For example: if you put your mouse close to the right edge of the monitor and open the menu. It doesnt matter what setting your computer has, the menu cant be displayed on the right side because it would overflow outside of the visible area of the monitor.

You might have a multi monitor setup and you are expecting the menu to be displayed in both windows maybe? that's still not something i have seen windows do with Menus specifically.

Before displaying the Menu I think the OS calls a function like CalculatePopupWindowPosition which as stated:
Use the CalculatePopupWindowPosition function to ensure that the pop-up window is fully visible on the desktop window, regardless of the specified anchor point.
It is highly likely that the OS calls that function (or one similar) before displaying the menu and to ensure it is always visible.

So yeah, you can set the settings to make the menus usually pop up to the right but there are certain circumstances that it would still pop up to the left due to not having enough space to be fully visible.
Projects:
AHK-ToolKit

Post Reply

Return to “Ask for Help (v2)”