「 GUI 」 一覧
-
Automate GUI Control [PowerShell]
2017/12/14 GUI, 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
12345678910111213141516171819202122232425262728#Press Windows key[System.Windows.Forms.SendKeys]::SendWait("^{ESC}")#Input "run"[System.Windows.Forms.SendKeys]::SendWait("run")Start-Sleep -s 1#Press Enter key[System.Windows.Forms.SendKeys]::SendWait("{ENTER}")Start-Sleep -s 1#Input "notepad"[System.Windows.Forms.SendKeys]::SendWait("notepad")[System.Windows.Forms.SendKeys]::SendWait("{ENTER}")Start-Sleep -s 1#Input "This is a test script"[System.Windows.Forms.SendKeys]::SendWait("This is a test script.")#Press Control+S key[System.Windows.Forms.SendKeys]::SendWait("^s")Start-Sleep -s 1[System.Windows.Forms.SendKeys]::SendWait("newtext.txt")[System.Windows.Forms.SendKeys]::SendWait("{ENTER}")Start-Sleep -s 1#Press Alt+F4 key[System.Windows.Forms.SendKeys]::SendWait("%{F4}")Explanation This script just press keys by SendKeys. The following page is the ...