RPAツールUiPathを使ってWindowsのターミナルから自動操作する。 UiPathにはCommunity Licenseがあって、個人や小規模のチームなら無料で使うことができる。 最近Microsoft公式のPower Automate Desktopも無料で使えるようになったが、 スケジューリングやトリガー機能を使うには有償のPower Autoamteを契約する必要があるようだ。
起動時にいくつかの選択肢が出るが最も多機能なUiPath Studio Proで空のプロジェクトを作成した。
$ tree -a -L 2 .
.
├── .entities
├── .local
│ ├── AllDependencies.json
│ ├── PackageCache.json
│ ├── db
│ └── nuget.cache
├── .settings
│ ├── Debug
│ └── Release
├── .tmh
│ └── config.json
├── Main.xaml
└── project.json
gitignoreには .local
だけ加えた。
シーケンスにクリックなどのアクティビティを追加していく。
$ cat Main.xaml
...
<ui:Click AlterIfDisabled="{x:Null}" CursorMotionType="{x:Null}" DelayBefore="{x:Null}" DelayMS="{x:Null}" SendWindowMessages="{x:Null}" SimulateClick="{x:Null}" ClickType="CLICK_DOUBLE" DisplayName="ダブル クリック" sap:VirtualizedContainerService.HintSize="334,106" sap2010:WorkflowViewState.IdRef="Click_1" KeyModifiers="None" MouseButton="BTN_LEFT">
<ui:Click.CursorPosition>
<ui:CursorPosition Position="Center">
<ui:CursorPosition.OffsetX>
<InArgument x:TypeArguments="x:Int32" />
</ui:CursorPosition.OffsetX>
<ui:CursorPosition.OffsetY>
<InArgument x:TypeArguments="x:Int32" />
</ui:CursorPosition.OffsetY>
</ui:CursorPosition>
</ui:Click.CursorPosition>
<ui:Click.Target>
<ui:Target ClippingRegion="{x:Null}" Element="{x:Null}" Id="ae700931-91db-4385-8512-24c726bbffd6" InformativeScreenshot="1529ca2ebd766c152c267254688a8f12" Selector="<wnd app='explorer.exe' cls='Progman' title='Program Manager' /><wnd cls='SysListView32' title='FolderView' /><ctrl name='デスクトップ' role='list' /><ctrl name='Slack' role='list item' />">
<ui:Target.TimeoutMS>
<InArgument x:TypeArguments="x:Int32" />
</ui:Target.TimeoutMS>
<ui:Target.WaitForReady>
<InArgument x:TypeArguments="ui:WaitForReady" />
</ui:Target.WaitForReady>
</ui:Target>
</ui:Click.Target>
</ui:Click>
UiRobot execute --file
でこのxamlを渡せばターミナルから実行できる。
$ C:\Users\****\AppData\Local\UiPath\app-21.4.3\UiRobot execute --file C:\Users\****\Documents\UiPath\test\Main.xaml
参考
How To Trigger A Process Using .bat File – In UiPath – ExcelCult
Is there a suggested .gitignore to use with UIPath Studio? - Help - UiPath Community Forum