Context Menu¶
ContextMenu ¶
Bases: BaseModel
A context menu representation.
Attributes:
| Name | Type | Description |
|---|---|---|
display_text |
str
|
The text that should be displayed for the context menu on right-click.
You can also use string localization, which tells Windows to look up a string resource from a DLL (or EXE) file.
For example |
command |
str | None
|
Add a command that gets executed when clicking the context menu. Use CommandPlaceholder. |
icon |
WindowsIcon | str | None
|
An icon that will be displayed for the context menu. Can be a windows dll/exe icon, or a path on the local machine for the icon. |
shift_click |
bool
|
Open context menu only when shift is pressed alongside right click. |
never_default |
bool
|
Prevents Windows from using this context-menu item when no default app is set for the file extension. |
no_working_directory |
bool
|
Don't use the clicked item's working directory path when opening the context menu item. Normally, Windows sets the working directory to the folder containing the file/folder/etc you clicked on. This can sometimes lead to unintended behavior if the program being launched makes assumptions about its working directory. By setting NoWorkingDirectory, Windows skips setting the working directory, and the program will inherit the default working directory (often C:\Windows\System32 or whatever the default is for the parent process).[^1] |
position |
Literal['Top', 'Bottom'] | None
|
Determines the general position of the context menu. Warning: This feature will NOT necessarily set the position. The way Windows determines the location is complicated, and Position feature merely specifies the general preference. For example, it may move your context menu lower down the list, but not all the way. |
separator |
Literal['After', 'Before'] | None
|
Adds a line separator before or after the context menu. Only works with submenus. [^2] |
has_lua_shield |
bool
|
Display a User Account Control (UAC) shield. Note: You can also use an Icon.[^3] |
disabled |
bool
|
Make the context menu disabled. |
note |
str | None
|
Add a note to the menu (will display in the registry). |
condition |
Condition | None
|
Add a condition for when the context menu should appear. It is recommended to initialize from a dictionary, for example: |
selection_limit |
Literal[1, 15, 100] | None
|
The maximum amount of simultaneously selected items the context menu supports. For example, when selecting 1, if more than 1 item (file/folder/etc.) is selected, right-clicking would not display the menu. |
submenus |
list[ContextMenu]
|
Sub-context menus. |