SetContextMenuHook
Installs a hook that automatically selects a specific entry from any context menu received for the specified object.
MenuID — serial (ID) of the object whose context menu should be hooked.
EntryNumber — zero-based index of the context menu entry to automatically select.
When a context menu for the matching object arrives from the server, the specified entry is automatically chosen and sent back to the server, as if the player had clicked it. The hook stays active and fires on every matching context menu — it is not consumed after the first use. To change the target or entry, call SetContextMenuHook again; to disable it, call SetContextMenuHook(0, 0).
Use RequestContextMenu to trigger the context menu after setting the hook.
Устанавливает перехватчик, который автоматически выбирает указанный пункт из любого полученного контекстного меню для заданного объекта.
MenuID — serial (ID) объекта, контекстное меню которого перехватывается.
EntryNumber — индекс пункта контекстного меню (с нуля), который будет автоматически выбран.
При получении контекстного меню для совпадающего объекта указанный пункт автоматически выбирается и отправляется серверу, как если бы игрок по нему кликнул. Перехватчик остаётся активным и срабатывает при каждом совпадающем контекстном меню — он не сбрасывается после первого использования. Чтобы сменить объект или пункт, вызовите SetContextMenuHook повторно; чтобы отключить — вызовите SetContextMenuHook(0, 0).
Используйте RequestContextMenu для вызова контекстного меню после установки перехватчика.
procedure SetContextMenuHook(MenuID: Cardinal; EntryNumber: Byte);
def SetContextMenuHook(MenuID: int, EntryNumber: int) -> None: ...
begin
// Hook to auto-select "Open Paperdoll" (entry 0) on self
SetContextMenuHook(Self, 0);
RequestContextMenu(Self);
Wait(1000);
AddToSystemJournal('Context menu hook triggered');
end.
# Hook to auto-select "Open Paperdoll" (entry 0) on self
SetContextMenuHook(Self(), 0)
RequestContextMenu(Self())
Wait(1000)
AddToSystemJournal('Context menu hook triggered')