Reputation: 1
I am working on the Java Access Bridge in c# for some time now. I finally got it to working, partly.
How do I take it from there? I tried to do things like set text, click or get text but was unable. I used the below code that was mentioned in another question, Automation using Java Access Bridge
Set text:
public string Text
{
get
{
return GetText();
}
set
{
if (!API.setTextContents(this.VmId, this.Context, value))
throw new AccessibilityException("Error setting text");
}
}
private string GetText()
{
System.Text.StringBuilder sbText = new System.Text.StringBuilder();
int caretIndex = 0;
while (true)
{
API.AccessibleTextItemsInfo ti = new API.AccessibleTextItemsInfo();
if (!API.getAccessibleTextItems(this.VmId, this.Context, ref ti, caretIndex))
throw new AccessibilityException("Error getting accessible text item information");
if (!string.IsNullOrEmpty(ti.sentence))
sbText.Append(ti.sentence);
else
break;
caretIndex = sbText.Length;
}
Click on a button:
public void Press()
{
DoAction("click");
}
protected void DoAction(params string[] actions)
{
API.AccessibleActionsToDo todo = new API.AccessibleActionsToDo()
{
actionInfo = new API.AccessibleActionInfo[API.MAX_ACTIONS_TO_DO],
actionsCount = actions.Length,
};
for (int i = 0, n = Math.Min(actions.Length, API.MAX_ACTIONS_TO_DO); i < n; i++)
todo.actionInfo[i].name = actions[i];
Int32 failure = 0;
if (!API.doAccessibleActions(this.VmId, this.Context, ref todo, ref failure))
throw new AccessibilityException("Error performing action");
}
Any ideas would be much appreciated. Thanks!!
Upvotes: 0
Views: 1067
Reputation: 380
doAccessibleActions
actually this function is not working at all, so, you must combine win32 api for doing alternative such as: set text
=> send key
, scroll ...
Upvotes: 0