I am currently try to find a bug in my software and it is easier to write an automated test for this case.
So i am searching for a way to automate ui interaction programatically, i.e. clicking on a button, enter text (like in .NET API https://msdn.microsoft.com/de-de/librar ... 10%29.aspx))
Does anybody know a solution?
With regards,
Frank Lindecke
UI Automation: How to set focus, click buttons, enter text programmatically
- flindecke
- Posts:69
- Joined: Wed Jun 24, 2015 1:54 pm
UI Automation: How to set focus, click buttons, enter text programmatically
- kilianvp
- Posts:443
- Joined: Fri Jan 16, 2015 10:29 am
Re: UI Automation: How to set focus, click buttons, enter text programmatically
if you have the Version 3.15 with last Patch you can use the new setCursorPosition Function.
and use nircmd.exe to send a mouse click.
and later you can do something like
and use nircmd.exe to send a mouse click.
Code: Select all
void clickButton(shape button)
{
dyn_int pos = button.positionAsDyn;
dyn_int size = button.sizeAsDyn;
int x = pos[1] + (size[1]/2);
int y = pos[2] + (size[2]/2);
setCursorPosition(x ,y);
string sdtout;
string sdterr;
string sSystemCall = getPath(BIN_REL_PATH,"nircmd.exe");
sSystemCall = sSystemCall + " sendmouse left click";
system("cmd /c "+sSystemCall, sdtout, sdterr);
delay(0,5);
}
and later you can do something like
Code: Select all
clickButton(getShape("PUSH_BUTTON1"));- flindecke
- Posts:69
- Joined: Wed Jun 24, 2015 1:54 pm
Re: UI Automation: How to set focus, click buttons, enter text programmatically
@Kilian von Pflugk You made my day
Now i need to find out the global position of a panel on the screen and i am finished.
Thanks for your tip
Now i need to find out the global position of a panel on the screen and i am finished.
Thanks for your tip
- kilianvp
- Posts:443
- Joined: Fri Jan 16, 2015 10:29 am
Re: UI Automation: How to set focus, click buttons, enter text programmatically
You can use
thats the left upper corner of the panel

Code: Select all
int x, y;
panelPosition("","",x,y);
- flindecke
- Posts:69
- Joined: Wed Jun 24, 2015 1:54 pm
Re: UI Automation: How to set focus, click buttons, enter text programmatically
In the meanwhile i found this function and added an offset (due to window title etc.)
It works like a charm.
As already mentioned: You made my day
It works like a charm.
As already mentioned: You made my day