Jump to content

ControlClick chooses the wrong context menu item when I provide position of the item


Cod
 Share

Recommended Posts

I am using autoIt to automate some test cases. I need to right-click which opens a context menu and then select the 6th item in the context menu. I tried to use Send("{}"), but it doesn't choose the 6th item and chooses randomly.

AutoIt Window Info shows only [CLASS:#32768] about the context menu.

I found another solution in a forum -

Local $putMsgHandle = WinGetHandle ( "[CLASS:#32768]" )
Local $putMsgMenu  =  _SendMessage ( $putMsgHandle ,  $MN_GETHMENU ,  0 ,  0 )
Local $putMsgRect  =  _GUICtrlMenu_GetItemRect ($putMsgHandle, $putMsgMenu, 6)
ControlClick("[CLASS:#32768]", "", "", "left", 1,  $putMsgRect[0], $putMsgRect[1])

This code works but sometimes it chooses the wrong option. While executing, there was no mouse movement, keyboard or pop-up etc. The application to be tested was the only one open.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...