T
T
TechNOIR2017-08-24 17:50:40
PowerShell
TechNOIR, 2017-08-24 17:50:40

Powershell. How to use to click on a button in a Windows program?

Good day, comrades.
I found on the Internet a library for automation for Powershell WASP called.
You can manage Windows GUI applications using Powershell.
Something I did not implement with the help of this library what is needed, can anyone tell me whether a solution is possible at all or not possible at all?
There is a program for Windows. There is a button on the program form that looks more like a text link.
How can I click on this button using Powershell? Suppose you specify "click on the button that contains the text "Button"".
Thanks to those who responded in advance.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
azarij, 2017-08-24
@TechNOIR

something like this:
Add-PSSnapin wasp
$window = Select-Window -ProcessName calc.exe | where title -eq "Calculator"
if ($window -ne $null)
{
$window.Activate()
$window.Restore()
Start-Sleep 1
Select-Control -Window $window.Handle -Recurse | where title -Match "text on button" | where class -Match "class button" | Send-Click -Button left
}

E
Ethril, 2017-08-24
@Ethril

WASP can automate GUI not in all programs. Depends on what the program is written in. If the GUI is based on bare WinForms, then Ok, but, for example, in Delphi WASP programs, it simply does not see the properties of most graphic elements.
PS In addition to WASP under powershell, there is also AutoItX, written by the authors of the notorious AutoIt. It has richer functionality, but Delphi is also too tough for it :)
PPS There is another class of programs that automate operations in any GUI at the image recognition level, for example, Sikuli.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question