Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Insert text #99

Open
stdex opened this issue Jan 6, 2019 · 4 comments
Open

Insert text #99

stdex opened this issue Jan 6, 2019 · 4 comments

Comments

@stdex
Copy link
Contributor

stdex commented Jan 6, 2019

Hello.

If I need implement something like this:
https://docs.microsoft.com/nl-nl/dotnet/framework/ui-automation/add-content-to-a-text-box-using-ui-automation

As I see I need method AutomationElement.TryGetCurrentPattern (with ValuePattern object) and method SendWait from System.Windows.Forms.SendKeys)

How can I do this?

@mmarquee
Copy link
Owner

mmarquee commented Jan 7, 2019

Essentially, but the library will do much of the work for you, so you would have to do something like this (which is hidden in one of the example programs)

        String text = applicationWindow.getEditBox(
                Search.getBuilder(1).build()).getValue();
        logger.info("Text for edit box 1 is " + text);

        applicationWindow.getEditBox(
                Search.getBuilder(1).build()).setValue("Hi");
        logger.info("Text for edit box 1 is now " +
                applicationWindow.getEditBox(
                        Search.getBuilder(1).build()).getValue());`

This gets the editbox, and does a setValue for it.

Is that what you mean? There might be better examples in the Develop branch, if not, Ill try to add some for each control

@stdex
Copy link
Contributor Author

stdex commented Jan 13, 2019

And how I can get Window object of current focused editbox?
I try to get it from Element (automation.getFocusedElement()), but it looks like I cannot do it this way.

@markhumphreysjhc
Copy link
Contributor

Only one element has focus, so it's an overall thing, a quick snippet I've just looked ...

Element focused = automation.getFocusedElement();
String v = focused.getClassName();
logger.info("Focused class-name is : " + v);

@markhumphreysjhc
Copy link
Contributor

The Element here is a 'raw' thing, so you'd have to know it was an EditBox (for example), and create an EditBox object to get at the EditBox specific functions, and Patterns

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants