Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Command Bars
  New Posts New Posts RSS Feed - Automating CommandBar
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Automating CommandBar

 Post Reply Post Reply
Author
Message
shuypens View Drop Down
Newbie
Newbie


Joined: 19 August 2010
Location: Belgium
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote shuypens Quote  Post ReplyReply Direct Link To This Post Topic: Automating CommandBar
    Posted: 20 August 2010 at 3:58am
I've already read a few post about not been able to automate CodeJock Commandbar with Quicktest Pro.
Quicktest Pro recognizes the commandbar as a Winobject, but does not recognize the menu items on the bar.
 
I need to be able to check if a menu item is enabled or disabled.
 
Is it possible to acces the commandbar object via Extern.declare.
 
Example with user32.dll
Extern.Declare micHwnd, "FindWindow", "user32.dll", "FindWindowA", micString, micString
 
Thanks.
Product: Xtreme SuitePro version 9.81
Platform: Windows XP (32bit) - SP 3
Language: Progress Edge
Back to Top
shuypens View Drop Down
Newbie
Newbie


Joined: 19 August 2010
Location: Belgium
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote shuypens Quote  Post ReplyReply Direct Link To This Post Posted: 30 August 2010 at 9:13am
I‘ve managed to access the command bar with MSAA. I’ve made a dll written in C# which can be called from QuickTest Pro. Hopefully this will help.

[DllImport("oleacc.dll")]

internal static extern int AccessibleObjectFromWindow(Int32 hwnd, uint id, ref Guid iid, [In, Out, MarshalAs(UnmanagedType.IUnknown)] ref object ppvObject);

 

[DllImport("oleacc.dll")]

public static extern uint AccessibleChildren(IAccessible paccContainer, int iChildStart, int cChildren, [Out] object[] rgvarChildren, out int pcObtained);

 

//hWnd is handle of the MenuBar in QTP you can retrieve this with the GetROProperty

//MenuPath is the path in the menu with “;” as delimiter. Example: View;Toolbars;Standard


public void ClickMenuPath(Int32 hWnd, string MenuPath)

{

IAccessible accObj;

IAccessible accChild;

 

accObj = GetAccessibleMenu(hWnd);

 

object[] objChildren = new object[accObj.accChildCount];

GetAccessibleChildren(0, accObj.accChildCount, objChildren, accObj);

accChild = (IAccessible)objChildren[2];

ClickPath(accChild, MenuPath, 0);

}



public void ClickMenuPath(Int32 hWnd, string MenuPath)

{

IAccessible accObj;

IAccessible accChild;

 

accObj = GetAccessibleMenu(hWnd);

 

object[] objChildren = new object[accObj.accChildCount];

GetAccessibleChildren(0, accObj.accChildCount, objChildren, accObj);

accChild = (IAccessible)objChildren[2];

ClickPath(accChild, MenuPath, 0);

}

 


private void ClickPath(IAccessible accChild, string strPath, int intArr)

{

IAccessible accChild2;

string[] words = strPath.Split(';');

int b = intArr;

 

object[] objChildren = new object[accChild.accChildCount];

GetAccessibleChildren(0, accChild.accChildCount, objChildren, accChild);

//if accessible object is a MenuPopup

if (accChild.get_accRole(0).ToString() == "12")

{

accChild = (IAccessible)objChildren[0];

objChildren = new object[accChild.accChildCount];

GetAccessibleChildren(0, accChild.accChildCount, objChildren, accChild);

            }

for (int a = 0; a < accChild.accChildCount; a++)

            {

accChild2 = (IAccessible)objChildren[a];

if (accChild2.get_accName(0).ToString() == words)

{

accChild2.accDoDefaultAction(0); //simulate click

b = b + 1;

if (b > words.GetUpperBound(0)) break;

ClickPath(accChild2, strPath, b);

            }

            }

}



private static IAccessible GetAccessibleMenu(Int32 hWnd)

{

Guid guid = new Guid("{618736E0-3C3D-11CF-810C-00AA00389B71}");

object accObj = null;

 

int retVal = AccessibleObjectFromWindow(hWnd, 0, ref guid, ref accObj);

return (IAccessible)accObj;

}

Product: Xtreme SuitePro version 9.81
Platform: Windows XP (32bit) - SP 3
Language: Progress Edge
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.156 seconds.