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
Select data in a list box using index
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
Thank you for this info, I could reproduce the error now with a VC 6.0 ListBox.Nik wrote:I am on WinXP and using VC++ (6.0)
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: Select all
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);
Jenö Herget
Ranorex Team
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
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:Thank you for this info, I could reproduce the error now with a VC 6.0 ListBox.Nik wrote:I am on WinXP and using VC++ (6.0)
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++:
Please contact me, if it doesn't work, i can send you another work around with Elements.Code: Select all
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);
Jenö Herget
Ranorex Team
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:
Sample code for selecting tree view items with elements:
I tested the samle code with VS2005Application.exe
Jenö Herget
Ranorex Team
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: Select all
...
// 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);
}
}
}
Code: Select all
...
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);
}
}
}
Jenö Herget
Ranorex Team
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
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
Try the function RxTreeViewSelectPath(), it should work with VS 6.0, but we test Ranorex only with Visual Studio 2003 and Visual Studio 2005.
Please use the Element functions, if you have a problem.
Jenö Herget
Ranorex Team
Code: Select all
/// <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);
Jenö Herget
Ranorex Team
OS support
Hi,
Just want to know if Ranorex APIs would work with Windows 98, ME and NT 4.x.
Thanks,
Nikhil
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.
Please use the Element functions, if you have a problem.Code: Select all
/// <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);
Jenö Herget
Ranorex Team
Ranorex should work with every Windows versions, but you must have MSAA 2.0 installed.Nikhil wrote:Just want to know if Ranorex APIs would work with Windows 98, ME and NT 4.x.
We test Ranorex only with Windows XP and Vista.
Please inform us about the results.
Jenö Herget
Ranorex Team
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?
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?
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.Stewie wrote:1. The API RxElementFindChild fails to find children for a particular element.
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.
We try to correct every bug as soon as possible, it's not trivial to automate an application in an other process.Stewie wrote:]4. Is Ranorex Opensource to allow others to provide fixes for better and reliable features?
I think we can provide a better quality this way.
Jenö Herget
Ranorex Team