Jump to content

How to automate menu selections when no active window


skid
 Share

Recommended Posts

As part of an automated test suite, I need to automate some menu selections in Google SketchUp. I have been able to do this relatively easily by using Send() and it works fine - as long as it is running on my local machine, or on a test server by remote desktop. If however, the remote desktop window is minimised, or the server is running without a rdp connection, Send() will not work as there is no active window to receive the keystrokes. I have tried various ways of forcing focus to the SketchUp window but none have been successful, including (in various combinations) WinActivate(), WinSetOnTop(), _WinAPI_EnableWindow(), _WinAPI_SetFocus()

I have tried several ways to get this to work:

$hWnd = WinGetHandle("SketchUp")
WinMenuSelectItem($hWnd, "", "&Window", "&Material" ) ;returns 0
$hMain = _GUICtrlMenu_GetMenu($hWnd) ;returns 0x0000000017D60DAF
$hSysMenu = _GUICtrlMenu_GetSystemMenu($hWnd, False) ;returns 0x0000000031940E67
$menudata = _GUICtrlMenu_GetMenuData($hMain) ;returns 0 called with either handle
$menuinfo = _GUICtrlMenu_GetMenuInfo($hMain) ;is empty called with either handle

so I tried getting a control ID...

$menuID = _GUICtrlMenu_GetItemID($hMain, 6) ;returns 1128992347
$sysmenuID = _GUICtrlMenu_GetItemID($hSysMenu, 6) ;returns 0

and used it with ControlSend()...

$check = ControlSend($hWnd, "", $menuID, "{!w}{DOWN 2}{ENTER}", 0) ;returns 0 - should launch the Material editor from the Window menu

and then based on this link:

$check = ControlSend($hWnd, "", "", "{!w}{DOWN 2}{ENTER}", 0) ;returns 1 (success!) - unfortunately this is misleading, as nothing actually happens (the material editor is not launched)

If anyone has any idea how I might accomplish this I would be very grateful to hear from you.

Thanks,

Martin

Link to comment
Share on other sites

Thanks for the quick reply.

Not trying to be thick but having looked over the IE section in the documentation, I'm not seeing the connection here as there is currently no browser in the equation.

I realise that some of the menus in SketchUp are HTML based and are dependent on IE, but the main menu that I'm trying to access isn't one of them...

Care to elaborate?

cheers,

Martin

Link to comment
Share on other sites

well, what happens when you select one of the controls using the AutoIt Window Info tool? Can you get an ID? Second, if you can't, then treat the window it operates in as a web based window and see if the IE tools can get info on what is in there. If that fails, then it may be chrome based. In that case, I'm not knowledgeable in that area.

Link to comment
Share on other sites

Using the AutoIt Window Info tool I can get ID's from everything in the main window except the main menu bar. (Same results using Winspector). I've checked with the developers here and they have told me that it's definitely only IE, no Chrome involvement, but the web based stuff is only used for dialogues and editors - not in the main interface which is apparently MFC.

I can get an ID from the menu by using _GUICtrlMenu_GetItemID(), but it doesn't seem to work with ControlSend() (unless I'm doing something very wrong...)

Thanks for your help. I'll have a fresh look at it (and the IE stuff) tomorrow morning...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...