Here is a listing for easier copy/paste.
A sample typing command text file is listed below:## Powershell script for Windows: TypeForMe.ps1# MAR. 18, 2022, by Li-Ji Hong (洪李吉, hongliji@gmail.com)## After starting this script, it will go to next active window, and type for me, according to selected typing command text file.## Typing command text file format's definition:## Any line begin with '#' is a short pause (default 200ms)# Windows special key strokes, refer to# https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-powershell-1.0/ff731008(v=technet.10)?redirectedfrom=MSDN# Others: type each printed characters.#param([string]$Filename=".\typing-commands.txt")add-type -AssemblyName System.Windows.Forms[System.Windows.Forms.SendKeys]::SendWait("%{TAB}")Start-Sleep -milliseconds 100$contents=Get-Content -encoding UTF8 $Filenameforeach ($line in $contents){if ($line -match '^#') {Start-Sleep -milliseconds 200continue}[System.Windows.Forms.SendKeys]::SendWait($line)[System.Windows.Forms.SendKeys]::SendWait("{ENTER}")}
#A pause of 200msThis is typed line 1.#A pause of 200ms#A pause of 200msThis is typed line 2.This is windows TAB key{TAB}tab.This is typed line 3.
No comments:
Post a Comment