1
Stealth Client / ContextMenu activate entry in open ContextMenu
« on: October 01, 2015, 04:50:26 AM »
Hi there,
My Problem:
Is there a way to activate a specific entry in an already open ContextMenu?
Why do I ask:
I have a problem regarding the context menu.
On my server we have a few skill trainer that can train your skill to high levels.
However the problem is that the index of the "Train <Skill>" entry is on a different position every time I open the ContextMenu.
My demo-Code:
SetContextMenuHook seems to open a new ContextMenu thus activating the wrong entry.
My Problem:
Is there a way to activate a specific entry in an already open ContextMenu?
Why do I ask:
I have a problem regarding the context menu.
On my server we have a few skill trainer that can train your skill to high levels.
However the problem is that the index of the "Train <Skill>" entry is on a different position every time I open the ContextMenu.
My demo-Code:
Code: [Select]
# SKILL is the context-entry that shall be activated to train the skill.
SKILL = 'Train Archery'
def getSellContextMenu(vendorId):
ClearContextMenu()
while GetContextMenu() == []:
RequestContextMenu(vendorId)
sleep(0.5)
contexts = GetContextMenu()
contNr = -1
# context is one line from the context menu.
for context in contexts:
if SKILL in context:
# Get the position of the found context entry.
contEntry = context.split('|', 1)[0]
# print 'ContextEntry: %s, number: %s' % (context, contEntry)
contNr = int(contEntry)
if contNr == -1:
# Skill was not found in the context menu.
return False
# Activate the found context-entry.
SetContextMenuHook(vendorId, contNr)
The problem of my demo code:SetContextMenuHook seems to open a new ContextMenu thus activating the wrong entry.