'================================================================
' FUNCTION NAME:
' SelectImageMenu
' FUNCTION DESCRIPTION:
' Use this function to right-click on a image object and select the pop-up menu
' FUNCTION USAGE:
' ret = SelectImageMenu(browser("test").Page("test").Image("image001"), "R")
' FUNCTION PARAMETER
' ImageObject : The web image object
' MenuKey : The hot key of pop-up menu item you will select
' FUNCTION RETURN:
' Return 0 when successfully, or return -1 when fail
'================================================================
Function SelectImageMenu(ImageObject, MenuKey)
Dim wshShell
Dim ieServerObject
Dim x1, y1
'Get the ie server object
Set ieServerObject = Window("regexpwndclass:=IEFrame").WinObject("regexpwndclass:=Internet Explorer_Server")
'get the image position
x1 = CInt(ImageObject.GetROProperty("abs_x"))
y1 = CInt(ImageObject.GetROProperty("abs_y"))
'right-click on image through ie object
ieServerObject.Click x1, y1, micRightBtn
wait 1
'Select the menu item by press hot key
Set wshShell = CreateObject("WScript.Shell")
wshShell.SendKeys MenuKey
wait 1