AutoHotkey라는 프로그램 들어 보신적 있나요? 매크로를 이용한 자동화 프로그램입니다.
저는 이 것과 유사하다고 느꼈습니다.
지원하는 Cmdlet은 아래와 같습니다.
Select-Window - pick windows by process name or window caption (with wildcard support)
Select-ChildWindow - pick all owned windows of another window (eg: dialogs, tool windows)
Select-Control - pick controls (children) of a specific window, by class and/or name and/or index (with wildcard support) -- NOTE: the "Window" can be specified as "-Window 0" to get all parentless windows, which includes windows, dialogs, tooltips, etc... With -Window 0 this returns a true superset of the Select-Window output.
Send-Click - send mouse clicks (any button, with any modifier keys)
Send-Keys - Windows.Forms.SendKeys lets you send keys ... try this: Select-Window notepad | Send-Keys "%(ea)Testing{Enter}{F5}" (and for extra fun, try it with multiple notepad windows open).
Set-WindowActive - yeah, just activates the window
Set-WindowPosition - set any one of (or all of) top, left, width, height on a window ... or maximize/minimize/restore
Get-WindowPosition - get the position (kind-of redundant, actually, since the Window object has it's position as a property)
Remove-Window - closes the specified window
Cmdlet을 보시면 느낌이 확 오시죠? 윈도우를 선택, 활성화,창크기 변경, 창 닫기, Keyboard,Mouse Action 등을 할 수 있습니다.
압축파일을 다운로드 하면 파일이 3개 있는데 이 중 Install.ps1을 파워쉘에서 실행하시면 됩니다.
저는 -Force 스위치를 사용하여 설치했습니다.
PS C:\Users\windian7.SDS\Downloads\WASP\WASP> dir
디렉터리: C:\Users\windian7.SDS\Downloads\WASP\WASP
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 2009-01-20 오전 12:50 2570 Install.ps1
-a--- 2009-01-20 오전 12:53 520 UnInstall.ps1
-a--- 2009-01-21 오전 11:13 43008 WASP.dll
PS C:\Users\windian7.SDS\Downloads\WASP\WASP> .\Install.ps1 -force
You're running PowerShell 2.0, so you don't need to Install this as a PSSnapin,
you can use Import-Module (or Add-Module in CTP2) to load it. If you still want
to install it as a PSSnapin, re-run this script with -Force
Microsoft (R) .NET Framework Installation utility Version 2.0.50727.4927
Copyright (c) Microsoft Corporation. All rights reserved.
트랜잭트 설치를 실행하고 있습니다.
설치의 Install 단계를 시작하고 있습니다.
C:\Users\windian7.SDS\Downloads\WASP\WASP\WASP.dll 어셈블리의 진행 상황을 보려면
로그 파일 내용을 검토하십시오.
파일은 C:\Users\windian7.SDS\Downloads\WASP\WASP\WASP.InstallLog 위치에 있습니다
.
어셈블리 'C:\Users\windian7.SDS\Downloads\WASP\WASP\WASP.dll'을(를) 설치하고 있
습니다.
영향을 받는 매개 변수:
assemblypath = C:\Users\windian7.SDS\Downloads\WASP\WASP\WASP.dll
logfile = C:\Users\windian7.SDS\Downloads\WASP\WASP\WASP.InstallLog
logtoconsole =
Install 단계는 완료되었으며 Commit 단계를 시작하고 있습니다.
C:\Users\windian7.SDS\Downloads\WASP\WASP\WASP.dll 어셈블리의 진행 상황을 보려면
로그 파일 내용을 검토하십시오.
파일은 C:\Users\windian7.SDS\Downloads\WASP\WASP\WASP.InstallLog 위치에 있습니다
.
어셈블리 'C:\Users\windian7.SDS\Downloads\WASP\WASP\WASP.dll'을(를) 커밋하고 있
습니다.
영향을 받는 매개 변수:
assemblypath = C:\Users\windian7.SDS\Downloads\WASP\WASP\WASP.dll
logfile = C:\Users\windian7.SDS\Downloads\WASP\WASP\WASP.InstallLog
logtoconsole =
Commit 단계가 완료되었습니다.
트랜잭트 설치가 완료되었습니다.
CommandType Name Definition
----------- ---- ----------
Cmdlet Get-WindowPosition Get-WindowPosition [-Window]...
Cmdlet Remove-Window Remove-Window [-Window] <Win...
Cmdlet Select-ChildWindow Select-ChildWindow [-Window]...
Cmdlet Select-Control Select-Control [[-Index] <In...
Cmdlet Select-Window Select-Window [[-ProcessName...
Cmdlet Send-Click Send-Click [[-Left] <Int32>]...
Cmdlet Send-Keys Send-Keys [-Keys] <String> [...
Cmdlet Set-WindowActive Set-WindowActive [-Window] <...
Cmdlet Set-WindowPosition Set-WindowPosition [[-Left] ...
To load the Windows Automation Snapin in the future, you need to run:
Add-PSSnapin WASP
You can also add that line to your Profile script to load it automatically.
설치 완료 후 다음 파워쉘 실행 시 "Add-PSSnapin WASP"을 통해서 스냅인을 로드해야 Cmdlet을 사용할 수 있습니다.
(프로필을 통해서 자동으로 로드 되도록 할 수도 있습니다.)
## "Remove-Window" Cmdlet을 통해 notepad를 종료합니다. 키 명령을 통해서 저장하지 않고 종료합니다.
Select-Window notepad | Select -First 1 | Remove-Window -Passthru | Select-ChildWindow | Send-Keys "n"
## ProcessID 파이프를 통해 Kill 명령으로 notepad를 종료합니다.
Select-Window notepad | Select -First 1 | kill
이렇게 파워쉘을 통해서 윈도우를 컨트롤 할 수 있습니다.
응용하기에 따라 유용한 도구가 될 것 같습니다.
그럼 다음 포스팅에서 뵙겠습니다.
PS. 스냅인 사용을 위해서는 Add-PSSanpin 명령을 통해 해당 스냅인을 로드해야 합니다. 기억하세요.
- Get-ExecutionPolicy 를 입력하시면 현재 설정된 실행정책(Execution_Policy)를 확인 할 수가 있습니다. 별도로 재설정을 하지 않았다면, 대부분 Restricted로 설정되어 있을 것 입니다. 이 실행정책을 변경하여 로컬에서 만든 스크립트를 실행 하려면 다음 명령을 입력하시면 됩니다.