Web里很多对象都有Click方法(object.Click [x], [y], [BUTTON]),带上micRightBtn参数,都能实现右键点击调出右键菜单的操作。
可是不知为何,Image对象就是不能右键点击,不管是否带上micRightBtn参数,Click执行的都是左键点击操作,所以无法调出右键菜单。
应朋友要求,研究了一番,找出替代的解决方法,写了一个函数,可供大家参考
| SelectImageMenu browser("test\").Page("test").Image("image001"), "R" |
| ' FUNCTION NAME: ' SelectImageMenu ' FUNCTION DEscrīptION: ' 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("Wscrīpt.Shell") wshShell.SendKeys MenuKey wait 1 SelectImageMenu = 0 End Function |

