WASP(Windows Automation Snapin for Powershell) http://wasp.codeplex.com/
윈도우를 선택, 활성화, 창 크기 변경, 창 닫기, Keyboard,Mouse Action 등을 할 수 있는 PowerShell 자동화 Snapin
Autohot Key 와 비슷한 기능들을 이용 가능할 것 같다.
사용 가능한 명령어들은 아래와 같다.
•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 |
WASP 1.3 RC 버전이 이글을 쓸때의 신버전이고(20100913) http://wasp.codeplex.com/releases/view/22118
설치는 압축을 해제하면 .아래 3개의 파일이 실행된다.
Install.ps1 UnInstall.ps1 WASP.dll |
PowerShell 을 실행 후 Install.ps1 을 실행하면 2.0이 설치되어있다고 PSSnapin을 이용해 Import-Module 을 하거나 -Force를 이용해서 하라고 한다.
PS C:\WASP> .\Install.ps1 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 |
-Force 명령을 실행하면 아래와 같이 설치가 진행 된다.
PS C:\WASP> .\Install.ps1 -force 트랜잭트 설치를 실행하고 있습니다. 설치의 Install 단계를 시작하고 있습니다. Install 단계는 완료되었으며 Commit 단계를 시작하고 있습니다. Commit 단계가 완료되었습니다. 트랜잭트 설치가 완료되었습니다. CommandType Name Definition You can also add that line to your Profile script to load it automatically. |
Sample Demo
## Open a couple windows(윈도우를 두개 실행) ## list the windows( 윈도우 리스트를 출력) ## Activate Notepad(노트패드를 활성화) ## Close Explorer( 탐색기 종료) ## Run a few more copies of notepad(노트패드를 여러개 실행) ## Move them around so we can see them all ... (Note the use of foreach with the incrementation)위치 변경 ## Put some text into them(텍스트를 입력) Select-Window notepad | Send-Keys "Test Send-Keys !!!" #### Close the first notepad window by pressing ALT+F4, and pressing Alt+N Select-Window notepad | Select -First 1 | Send-Keys "%{F4}" ## Close the next notepad window ... ## Close the next notepad window the hard way Select-Window notepad | Select -First 1 | kill ## A different way to confirm Don't Save (use CLICK instead of keyboard) Select-Window notepad | Select -First 1 | Remove-Window -Passthru | Select-childwindow | select-control| select-control| select-control -title "Do&n't Save" | Send-Click ## But now we have the new -Recurse parameter, so it's easy. Just find the window you want and ... Select-Window notepad | Select -First 1 | Remove-Window -Passthru | Select-childwindow | select-control -title "Do&n't Save" -recurse | Send-Click |
댓글 없음:
댓글 쓰기