Everything seems to work using InvokeRemotely. It even works with delegates in my code, so I won't have to change the code for our product, which is a plus.
I had to do a custom implementation of the control to be able to cast it as a Ranorex.Control (from Ranorex.ComboBox).
For those who might need it, here's the code I used :
Custom implementation
- Code: Select all
/// <summary>
/// Janus combobox overrided for detection with Ranorex
/// </summary>
public class CustomUiComboBox : UIComboBox
{
protected override AccessibleObject CreateAccessibilityInstance()
{
return new AccessibleUiComboBox(this);
}
}
public class AccessibleUiComboBox : AccessibleObject
{
private CustomUiComboBox _comboBox;
public override AccessibleRole Role
{
get
{
return AccessibleRole.ComboBox;
}
}
}
I had a few more Accessibility overrides, but from what I understand it's the Role that allowed me to convert it as a Control.
- Code: Select all
public static class ComboBoxTools
{
private static readonly RepoMainWindow Repo = RepoMainWindow.Instance;
public static int GetNumberOfItems(RxPath cboPath)
{
var control = (Control)Repo.HOST.HOST.FindSingle(cboPath);
var test = control.InvokeRemotely(GetNumberOfItemsDelegate);
return (int) test;
}
public static object GetNumberOfItemsDelegate(System.Windows.Forms.Control control, object input)
{
return ((UIComboBox) control).Items.Count;
}
}
If only I knew earlier this was possible

Back to refactoring!
Thanks a lot for the support (Both Ciege and the team).