PDA

View Full Version : Run menu item : browser


janaknayangaljanak
07-12-2012, 08:14 AM
Hello,

I have a menu entry for MENUITEM_BROWSER and i want to trigger this menu item programmatically.


how can i do that ?

thanx

Dougsg38p
07-12-2012, 10:56 AM
Where would you be triggering this from?

You can't programmatically invoke a menu item on another application from your application using the API's.

You might possibly be able to use key event injection (simulating keys pressed), but you would then have to identify when the browser is in focus and it is appropriate for you to press ths menu item.

My guess is that you are taking the long way around the block. What exactly is your use-case?

janaknayangaljanak
07-13-2012, 02:07 AM
I am using the code given bellow to run menu item when call initiated.

private void runMenuItem(String menuItemText) {
Screen screen = Ui.getUiEngine().getActiveScreen();
Menu menu = screen.getMenu(0);
for (int i = 0, cnt = menu.getSize(); i < cnt; i++)
if(menu.getItem(i).toString().equalsIgnoreCase(menuItemText))
menu.getItem(i).run();
}

but it's not working in case of browser.