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.