When the XBrowser tech domain is loaded, it prevents the recognition of the MenuItem controls of a context menu. Using Silk4J we can script around this limitation by unloading the XBrowser tech domain and loading only the WIN32 tech domain. The following sample code demonstrates how we can create a method that will invoke a context menu at the current mouse location and then select a MenuItem control from that menu:

public void openContextSelect(int xPos, int yPos, String sItem){

//load the win32 tech domain only
desktop.attach("*\\IEXPLORE.EXE", TechDomain.WIN32);

//Find the Browser and open menu
Window wMainWin = desktop.find("//Window[@caption='*Windows Internet Explorer']");
wMainWin.openContextMenu(new Point(xPos, yPos));

//select the item
Control cFP = desktop.find("//Window[@caption='*Windows Internet Explorer']//Control[@caption='*Windows Internet Explorer']");

//reload relevant tech domains
desktop.attach("*\\IEXPLORE.EXE", TechDomain.WIN32, TechDomain.XBROWSER, TechDomain.FLEX);

//Allow tech domains to reload


To use the above method, we would first have to move the mouse over the control on which we want to invoke the context menu and then call the above method:

public voidinteractWithMenu() {


desktop.find("//BrowserApplication//BrowserWindow//FlexApplication[@caption='explorer']//FlexButton[@caption='Button with Icon']").mouseMove();


x, MouseInfo.getPointerInfo().getLocation().y, "MyMenuItem");

desktop.find("//BrowserApplication//BrowserWindow//FlexApplication[@caption='explorer']//FlexButton[@caption='Button with Icon']").click();


When determining the x and y position of the mouse the MouseInfo class is used, this class is provided in the java.awt package.