| View previous topic :: View next topic |
| Author |
Message |
Nik
Joined: 29 Sep 2006 Posts: 18
|
Posted: Fri Sep 29, 2006 2:42 am Post subject: Select data in a list box using index |
|
Hi,
I am not able to use RxListBoxSetSelectedIndex(hListControl1, 1);
function.
Executing this line closes the application on test.
However, I am able to use RxListBoxGetItemCount function.
As I understand the behaviour of RxListBoxSetSelectedIndex function, this will highlight the text on the index I'll provide, right?
This is my code:
HWND hListControl = RxFormFindChildClassName(form, "ListBox",1);
int playcount = RxListBoxGetItemCount( hListControl ) ;
playcount = RxListBoxSetSelectedIndex(hListControl,3 );
Is there any step am missing?
-Nikhil |
|
| Back to top |
|
 |
Nik
Joined: 29 Sep 2006 Posts: 18
|
Posted: Fri Sep 29, 2006 11:55 pm Post subject: Re: Select data in a list box using index |
|
| Nik wrote: |
Hi,
I am not able to use RxListBoxSetSelectedIndex(hListControl1, 1);
function.
Executing this line closes the application on test.
However, I am able to use RxListBoxGetItemCount function.
As I understand the behaviour of RxListBoxSetSelectedIndex function, this will highlight the text on the index I'll provide, right?
This is my code:
HWND hListControl = RxFormFindChildClassName(form, "ListBox",1);
int playcount = RxListBoxGetItemCount( hListControl ) ;
playcount = RxListBoxSetSelectedIndex(hListControl,3 );
I am on WinXP and using VC++ (6.0)
Is there any step am missing?
-Nikhil |
|
|
| Back to top |
|
 |
admin Site Admin
Joined: 05 Jul 2006 Posts: 351
|
Posted: Sat Sep 30, 2006 1:26 am Post subject: |
|
| Nik wrote: |
| I am on WinXP and using VC++ (6.0) |
Thank you for this info, I could reproduce the error now with a VC 6.0 ListBox.
It's a bug in RanorexCore, I will fix it for the next version: 0.9.4.
But you can use the following code in C++:
Code: click into code to enlarge
HWND hListControl = RxFormFindChildClassName(form, "ListBox",1);
if ( hListControl == 0 )
{
printf(" ERROR: ListBox not found\n");
exit(1);
}
int itemCount = RxListBoxGetItemCount( hListControl );
// int selectedIndex = RxListBoxSetSelectedIndex(hListControl, 3);
int ret = ::SendMessage(hListControl, LB_SETCURSEL, 3, 0);
Please contact me, if it doesn't work, i can send you another work around with Elements.
Jenö Herget
Ranorex Team |
|
| Back to top |
|
 |
Nik
Joined: 29 Sep 2006 Posts: 18
|
Posted: Sat Sep 30, 2006 2:38 am Post subject: SendMessage not working on Listbox |
|
hi,
It is still not working with SendMessage. But the good thing is the application is not getting closed.
Pls send me the workaround using elements.
I am also working with TreeView. I am not able to select a path or folder in a tree.
The command I am using is
RxTreeViewSelectItem(hTreeControl, "Sample");
// where sample is the name of the folder. Here also I have to use the elements??
I appreciate your help.
-Nikhil
| admin wrote: |
| Nik wrote: |
| I am on WinXP and using VC++ (6.0) |
Thank you for this info, I could reproduce the error now with a VC 6.0 ListBox.
It's a bug in RanorexCore, I will fix it for the next version: 0.9.4.
But you can use the following code in C++:
Code: click into code to enlarge
HWND hListControl = RxFormFindChildClassName(form, "ListBox",1);
if ( hListControl == 0 )
{
printf(" ERROR: ListBox not found\n");
exit(1);
}
int itemCount = RxListBoxGetItemCount( hListControl );
// int selectedIndex = RxListBoxSetSelectedIndex(hListControl, 3);
int ret = ::SendMessage(hListControl, LB_SETCURSEL, 3, 0);
Please contact me, if it doesn't work, i can send you another work around with Elements.
Jenö Herget
Ranorex Team |
|
|
| Back to top |
|
 |
admin Site Admin
Joined: 05 Jul 2006 Posts: 351
|
Posted: Sat Sep 30, 2006 4:08 pm Post subject: |
|
Are you sure, that you use the correct ListBox handle? Please check it with RanorexSpy.
It's a better way to Find a control with RxFormFindChildControlName (for .NET controls, if you have a ControlName in RanorexSpy) or RxFormFindChildControlId (for older controls without a control name).
A ControlName is a unique identifier in a .NET form and a ControlId is a unique identifies in older windows applications or dialogs.
Sample code for selecting list box items with elements:
Code: click into code to enlarge
...
// Get the Element of the ListBox
ElementStruct element;
if ( RxControlGetElement(hListControl, &element) == FALSE)
{
printf(" ERROR: ListBox GetElement\n");
return 1;
}
// Find and select the list item with the name Item3
ElementStruct listItem;
BOOL bRet = RxElementFindChild(&element, ROLE_SYSTEM_LISTITEM, "Item3", NULL, &listItem);
if (bRet==TRUE)
{
printf(" List item found\n");
RxElementSelect(&listItem, SELFLAG_TAKEFOCUS | SELFLAG_TAKESELECTION);
RxSleep(500);
}
// Dump out all list items
ElementStruct listElement;
if ( RxElementFindChild(&element, ROLE_SYSTEM_LIST, NULL, NULL, &listElement) == TRUE )
{
int childCount = RxElementGetChildCount(&listElement);
for(int i=0; i< childCount; i++)
{
if ( RxElementGetChild(&listElement, i, &listItem) == TRUE )
{
printf(" Item(%d)=%s\n",i,listItem.Name);
RxElementSelect(&listItem, SELFLAG_TAKEFOCUS | SELFLAG_TAKESELECTION);
RxSleep(300);
}
}
}
Sample code for selecting tree view items with elements:
Code: click into code to enlarge
...
HWND hTreeView = RxFormFindChildControlName(form, "treeView1");
if ( hTreeView == 0 )
{
printf(" ERROR: TreeView not found\n");
return 1;
}
// Get the Element of the TreeView
ElementStruct element;
if ( RxControlGetElement(hTreeView, &element) == FALSE)
{
printf(" ERROR: TreeView GetElement\n");
return 1;
}
// Find and select the tree item with the name SecondNode
ElementStruct treeItem;
bRet = RxElementFindChild(&element, ROLE_SYSTEM_OUTLINEITEM, "SecondNode", NULL, &treeItem);
if (bRet==TRUE)
{
printf(" Tree item found\n");
RxElementSelect(&treeItem, SELFLAG_TAKEFOCUS | SELFLAG_TAKESELECTION);
RxSleep(1000);
}
// Dump out all tree items
ElementStruct treeElement;
if ( RxElementFindChild(&element, ROLE_SYSTEM_OUTLINE, NULL, NULL, &treeElement) == TRUE )
{
int childCount = RxElementGetChildCount(&treeElement);
for(int i=0; i< childCount; i++)
{
if ( RxElementGetChild(&treeElement, i, &treeItem) == TRUE )
{
printf(" Item(%d)=%s\n",i,treeItem.Name);
RxElementSelect(&treeItem, SELFLAG_TAKEFOCUS | SELFLAG_TAKESELECTION);
RxSleep(300);
}
}
}
I tested the samle code with VS2005Application.exe
Jenö Herget
Ranorex Team |
|
| Back to top |
|
 |
Nik
Joined: 29 Sep 2006 Posts: 18
|
Posted: Sun Oct 01, 2006 8:15 am Post subject: Re: Select data in a list box using index |
|
hi,
Listbox is now working for me. Thanks.
In the tree view, if i have to select embedded folder e.g. C:\folder1\folder2\folder3. Is there a direct command or I have to go be the element way?
Please advice.
I appreciate your quick responses.
-Nikhil
| Nik wrote: |
Hi,
I am not able to use RxListBoxSetSelectedIndex(hListControl1, 1);
function.
Executing this line closes the application on test.
However, I am able to use RxListBoxGetItemCount function.
As I understand the behaviour of RxListBoxSetSelectedIndex function, this will highlight the text on the index I'll provide, right?
This is my code:
HWND hListControl = RxFormFindChildClassName(form, "ListBox",1);
int playcount = RxListBoxGetItemCount( hListControl ) ;
playcount = RxListBoxSetSelectedIndex(hListControl,3 );
Is there any step am missing?
-Nikhil |
|
|
| Back to top |
|
 |
admin Site Admin
Joined: 05 Jul 2006 Posts: 351
|
Posted: Sun Oct 01, 2006 11:11 am Post subject: |
|
Try the function RxTreeViewSelectPath(), it should work with VS 6.0, but we test Ranorex only with Visual Studio 2003 and Visual Studio 2005.
Code: click into code to enlarge
/// <summary>
/// The function selects the specified tree-view path and
/// scrolls the item into view
/// The elements of the path will be separeted with "/".
/// Example of itemPath: "Rootname/SubItemName/SubSubItemName"
/// </summary>
/// <param name="hWnd">Handle to the treeview.</param>
/// <param name="itemPath">Item path.</param>
/// <returns>
/// If the function succeeds, the return value is zero,
/// otherwise the return value is an error code.
/// </returns>
RANOREXCORE_API int RxTreeViewSelectPath(HWND hWnd, char* itemPath);
Please use the Element functions, if you have a problem.
Jenö Herget
Ranorex Team |
|
| Back to top |
|
 |
Nik
Joined: 29 Sep 2006 Posts: 18
|
Posted: Mon Oct 02, 2006 8:35 pm Post subject: OS support |
|
Hi,
Just want to know if Ranorex APIs would work with Windows 98, ME and NT 4.x.
Thanks,
Nikhil
| admin wrote: |
Try the function RxTreeViewSelectPath(), it should work with VS 6.0, but we test Ranorex only with Visual Studio 2003 and Visual Studio 2005.
Code: click into code to enlarge
/// <summary>
/// The function selects the specified tree-view path and
/// scrolls the item into view
/// The elements of the path will be separeted with "/".
/// Example of itemPath: "Rootname/SubItemName/SubSubItemName"
/// </summary>
/// <param name="hWnd">Handle to the treeview.</param>
/// <param name="itemPath">Item path.</param>
/// <returns>
/// If the function succeeds, the return value is zero,
/// otherwise the return value is an error code.
/// </returns>
RANOREXCORE_API int RxTreeViewSelectPath(HWND hWnd, char* itemPath);
Please use the Element functions, if you have a problem.
Jenö Herget
Ranorex Team |
|
|
| Back to top |
|
 |
admin Site Admin
Joined: 05 Jul 2006 Posts: 351
|
Posted: Mon Oct 02, 2006 9:14 pm Post subject: |
|
| Nikhil wrote: |
Just want to know if Ranorex APIs would work with Windows 98, ME and NT 4.x.
|
Ranorex should work with every Windows versions, but you must have MSAA 2.0 installed.
We test Ranorex only with Windows XP and Vista.
Please inform us about the results.
Jenö Herget
Ranorex Team |
|
| Back to top |
|
 |
Stewie
Joined: 07 Oct 2006 Posts: 1
|
Posted: Sat Oct 07, 2006 12:49 pm Post subject: TreeNavigation using Element functions |
|
1. The above provided solution to navigation works for navigating through top level nodes. The API RxElementFindChild fails to find children for a particular elemnt. Is this functionality tested?
2. The TreeView API work to navigate through children, but there is no mechanism to perfom actions on the selected item. Is there anyway I can get Element struct from hItem?
3. When you say VS 2003 or 2005 are you referring to only managed managed code?
4. Is RanoRex Opensource to allow others to provide fixes for better and reliable features? |
|
| Back to top |
|
 |
admin Site Admin
Joined: 05 Jul 2006 Posts: 351
|
Posted: Sat Oct 07, 2006 2:34 pm Post subject: |
|
| Stewie wrote: |
| 1. The API RxElementFindChild fails to find children for a particular element. |
If the function RxElementFindChild() fails, then you should use RanorexSpy to retrieve the correct Role, Name and ClassName of the searched elements. If you use an incorrect argument, the function returns false.
Please study the other (Python, C#) samples and the DumpElementTree function. I'm sorry but we have a poor documentation for C++ user at the moment, you can find some useful information in RanorexNet.chm: Role Enumeration, Selection Enumeration, State Enumeration.
| Stewie wrote: |
| 2. The TreeView API work to navigate through children, but there is no mechanism to perfom actions on the selected item. Is there anyway I can get Element struct from hItem? |
You can use the following functions in C++ for every element (every tree view item) at the moment:
RxElementSelect()
RxElementGetValue()
RxElementSetValue()
RxElementGetState()
RxElementGetDefaultAction()
RxElementDoDefaultAction()
RxElementGetDescription()
RxElementGetHelp()
| Stewie wrote: |
| 3. When you say VS 2003 or 2005 are you referring to only managed code? |
No, all RanorexCore functions should work both with managed and unmanaged code.
| Stewie wrote: |
| ]4. Is Ranorex Opensource to allow others to provide fixes for better and reliable features? |
We try to correct every bug as soon as possible, it's not trivial to automate an application in an other process.
I think we can provide a better quality this way.
Jenö Herget
Ranorex Team |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|