Having trouble drilling down through menus

General discussion about the Phantom Automation Language and related tools.

Having trouble drilling down through menus

Postby pete on Tue Nov 23, 2010 10:02 pm

The application I'm trying to automate has multiple menu layers. It seems I can only drill down through one menu. If I try to drill through more than that, the script just terminates without telling me what I'm doing wrong. Any clues what I'm up against?
pete
 
Posts: 1
Joined: Tue Nov 23, 2010 9:55 pm

Re: Having trouble drilling down through menus

Postby john on Wed Dec 01, 2010 6:42 pm

Hi Pete-

How are you automating the menus? Are you using window declarations? Or TypeKeys or MouseClick, or is it a recorded script? Can you post a section of code where the problem occurs?

-John
john
 
Posts: 27
Joined: Wed Apr 22, 2009 12:32 pm

Re: Having trouble drilling down through menus

Postby Mark on Thu Dec 09, 2010 4:03 pm

Similar problems for me. I am using a windows declarations file which seems to have identified the structure correctly. However,

<window>.<topmenu>.<menuitem>.Select(); # works fine
<window>.<topmenu>.<menu>.<menuitem>.Select(); # no error, but menu function not invoked
Mark
 
Posts: 5
Joined: Thu Dec 09, 2010 2:48 am

Re: Having trouble drilling down through menus

Postby john on Mon Dec 13, 2010 8:00 pm

Hi All-

Quick question on this: Are you able to automate the menu selection on the Phantom Target test application?

Code: Select all
use "PhantomTarget.dec";
PhantomTarget._Menus._Cascade.Item_1.Select();


Also, can someone send me a .dec file of the window that is causing this? I am not able to reproduce this. Obviously a Phantom terminating a script without cause is a concern, so I would like to be able to reproduce this.

-John
john
 
Posts: 27
Joined: Wed Apr 22, 2009 12:32 pm

Re: Having trouble drilling down through menus

Postby Mark on Wed Dec 15, 2010 3:36 pm

I did some experimenting with the Phantom Target test application. As in my app, when I select the menu items on the cascade menus, nothing appears to happen. I thought I might see the menus expand, but I do not. In the Phantom app, however, nothing is supposed to happen when you select the lower menu items, so it is possible that the item *is* being selected. In my app, actions are supposed to happen and they do not which is why I believe the menu item is not truly being selected.

I did select the "Checked" item to ensure that something was happening and although I don't see the menu expand, "Checked" does get un-checked. This item is at the top of the menu hierarchy however. In terms of the Phantom app, it would be beneficial to have one of the menu items in the cascaded menus be one of the "Checked" type items or open a dialog box of some kind.

I also experimented with MouseClicks and MouseMoves to navigate the cascading menu structure and they work fine and do have the added benefit of giving you a visual feedback.

Here is my code.

Code: Select all
# test for cascading menus

use "PhantomTarget.dec";                                 # include the PhantomTarget dec file

System("C:\Program Files\Phantom\PhantomTarget.exe");    # start the PhantomTarget app

SetDelay(200);
PhantomTarget._Menus.C_hecked.Select();                  # top level - unchecks
Sleep(2.0);
PhantomTarget._Menus._Cascade.Item_1.Select();           # second level
Sleep(2.0);
PhantomTarget._Menus._Cascade._Cascade.Item_1.Select();  # third level
Sleep(2.0);
PhantomTarget.MouseClick(0,125,-10,0);                   # click Menus
PhantomTarget.MouseClick(0,150, 40,0);                   # click Cascade
PhantomTarget.MouseMove(   250, 40  );                   # move to Item1
PhantomTarget.MouseClick(0,250, 75,0);                   # click Cascade
PhantomTarget.MouseMove(   325, 75  );                   # move to Item1

#PhantomTarget.Close();                       # close app
Mark
 
Posts: 5
Joined: Thu Dec 09, 2010 2:48 am

Re: Having trouble drilling down through menus

Postby john on Wed Dec 15, 2010 5:16 pm

Hello-

In PhantomTarget, you can verify if a menu is selected by selecting Options->MessageBox->Menus from the main menu (in this case, it would have to be done manually since the objective of the test is to determine if cascading menus work). This will cause a message box to appear when the menu is selected.

If the selections work on the Phantom Target, and not in your application, then for some reason the application is not responding to the internal Windows menu selection messages (WM_MENUSELECT). Unfortunately, in this case, Phantom cannot use the Select() function. The only alternative is to use either menu accelerator keys if they are available (and the TypeKeys function), or use arrow keys to navigate menus:

Code: Select all
# Uses Accelerator Keys to select the menu
PhantomTarget.SetActive();
PhantomTarget.TypeKeys("<ALT-M>cc1");  # Selects Menu->Cascade->Cascade->Item1

# Uses the keyboard arrow keys to select the menu after using ALT+space to activate the menus
PhantomTarget.SetActive();
PhantomTarget.TypeKeys("<ALT-SPACE><LEFT><LEFT><LEFT><DOWN><DOWN><RIGHT><DOWN><DOWN><RIGHT><ENTER>"); # Selects Menu->Cascade->Cascade->Item1


This should be more robust than using the mouse. Things will happen very fast in this example, so if you want to see each selection, separate the TypeKeys commands to separate statements:

Code: Select all
PhantomTarget.SetActive();
PhantomTarget.TypeKeys("<ALT-M>");
PhantomTarget.TypeKeys("c");
PhantomTarget.TypeKeys("c");
PhantomTarget.TypeKeys("1");


-John
john
 
Posts: 27
Joined: Wed Apr 22, 2009 12:32 pm

Re: Having trouble drilling down through menus

Postby Mark on Tue Dec 21, 2010 5:03 pm

Thanks for the tip on Options->MessageBox->Menus. I should have known there was a way to do this.

I reran the code from my earlier post and get a good msgbox for the 'Checked' item. However, for each of the 'Cascade' menus that I try, the msgbox indicates that it selected the Graphic (PhantomTarget.Menus.Graphic1.Pick). So rather than making it through the menus, it seems to have defaulted to the first item in Menus. I don't know what the issue is, but it would appear that the Select() function on cascading menus is not going to work on my system.

I did try the TypeKeys function to use the accelerator keys and that worked well.
Mark
 
Posts: 5
Joined: Thu Dec 09, 2010 2:48 am


Return to Phantom

Who is online

Users browsing this forum: No registered users and 5 guests

cron