IT automation and programming tips

Jidouka.work

Windows

Automate GUI Control [PowerShell]

投稿日:

PowerShell script can simulate keyboard stroke.
This behavior can automate applications which do not support command line.

At this time, I made a script which run Notepad, input text and save it as a file.

Code

Explanation

This script just press keys by SendKeys.

The following page is the detail about keys.

VBScript - SendKeys Method - TechNet Articles - United States (English) - TechNet Wiki

Pressing Windows key cannot be simulated with another key. The script press Control+ESC, then input "run" and press enter.
In addition, there is a delay between pressing a key and showing dialog. A wait (1 second) may be needed to input a string.

Movie

The script is executed fast.
Basically, writing text and save it is done by a script (Not necessary to control GUI). However I made a script as an experiment.

powershell_keystroke


-Windows
-,

Copyright© Jidouka.work , 2024 All Rights Reserved.