Windows_Router Memo/Power Automate Desktop
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
]
開始行:
*Power Automate Desktop [#jf259e71]
RIGHT:更新日&lastmod();
RIGHT:作成日:2024年11月7日
Power Automate DesktopはWindowsのソフトの起動、メニュー操...
**インストール [#aef24286]
-Windows11
既に入っているので、power automateでアプリを検索する
-Windows10
以下からPower Automate インストーラーをダウンロードしてイ...
--https://learn.microsoft.com/ja-jp/power-automate/deskto...
**起動 [#rf5b8b4a]
起動するとMSアカウントでログインを求められるので、ログイ...
起動すると以下のような画面にになる
&ref("./起動.png");
自分のフローに移動して、「新しいフロー」を選択する。
&ref("./起動2.png");
フローを作成する画面で、フロー名を入力して作成ボタンを押...
&ref("./起動3.png");
以下の作成画面が開く
&ref("./起動4.png");
左ペインのアクションから中央のペインのMainのペインにドラ...
&ref("./起動5.png");
**サンプル作成 [#ifcdf024]
***アクション内容 [#m4d7c926]
以下の手順でアプリケーションを起動させ、起動画面を表示さ...
+目的のアプリケーションを起動
+PADのコンソールを終了
+所定の画面が表示するまで待機
+メニューバーから目的のメニュ−を選択(階層になっているた...
+所定の画面が表示するまで待機
+矢印キーを2つ押して、Enterキーを入力
+テキストフィールドにファーカスをあてる
+テキストフィールドに文字列を入力して、Enterキーを入力
+二つ目のテキストフィールドにファーカスをあて文字列を入力...
***アクション内容入力 [#r0ec1d91]
-�.▲�ション「アプリケーションの実行」~
アプリケーションのフルパスを指定。~
&ref("./アプリケーションの実行.png");
-��PADでプログラムが起動してもPADコンソールがデスクトップ...
ALT+F4で終了させる
&ref("./コンソールの終了.png");
-�L榲�の画面の表示を待つ。そのWindowをUI要素で指定する。
&ref("./Window待機1.png");
-�こ�層メニューバーからメニューを選択。3階層なので、アクシ...
&ref("./メニュー選択.png");
-�Σ爾笄�を2つ入力してEnterを入力
&ref("./キー入力.png");
-�А銑� 同じアクションを2つ実行
&ref("./テキストボックス入力.png");
***メニューバーから選択をサーバアドレスが表示している個所...
-メニューバーから選択3つのアクションの無効化
&ref("./アクション無効化.png");
-サーバアドレス部を画像して認識させクリックする
&ref("./画像にマウスを移動してクリック.png");
&ref("./画像にマウスを移動してクリック2.png");
***保存画像の削除 [#yc6387a1]
&ref("./保存画像削除.png");
&ref("./保存画像削除2.png");
***ショートカット作成 [#tf91efdd]
-Windows11
PowerShellを作成して以下のようなスクリプトを作成してその...
-kidou.ps1
# Power Automate for desktopのフローを実行するPowerShell...
# @param [string] $flowName 実行するフロー名
# @param [bool] $flgExit PAD終了フラグ
#
# 動作確認:バージョン 2.40.157.24023 (インストーラー版)
#
Param(
[bool]$flgExit = $false
)
#Power Automate for desktop起動
Start-Process -FilePath "ms-powerautomate://"
#UI Automation
Add-Type -AssemblyName "UIAutomationClient"
Add-Type -AssemblyName "UIAutomationTypes"
$uiAuto = [System.Windows.Automation.AutomationElement]
$pcdn = [System.Windows.Automation.PropertyCondition]
$acdn = [System.Windows.Automation.AndCondition]
$tree = [System.Windows.Automation.TreeScope]
$iptn = [System.Windows.Automation.InvokePattern]::Pattern
$wptn = [System.Windows.Automation.WindowPattern]::Pattern
$icptn = [System.Windows.Automation.ItemContainerPattern...
$siptn = [System.Windows.Automation.ScrollItemPattern]::...
$selptn = [System.Windows.Automation.SelectionItemPatter...
$root = $uiAuto::RootElement
#Power Automate for desktopウィンドウ取得
$cndPadWindowId = New-Object $pcdn($uiAuto::AutomationId...
$cndPadWindowClassName = New-Object $pcdn($uiAuto::Class...
$cndPadWindow = New-Object $acdn($cndPadWindowId, $cndPa...
do{
Start-Sleep -m 200
$elmPadWindow = $root.FindFirst($tree::Children, $cndP...
}while($elmPadWindow -eq $null)
#タブ取得
$cndTab = New-Object $pcdn($uiAuto::AutomationIdProperty...
$elmTab = $elmPadWindow.FindFirst($tree::Subtree, $cndTab)
#タブ項目取得・選択
if($elmTab -ne $null){
$cndTabItem = New-Object $pcdn($uiAuto::AutomationIdPr...
$elmTabItem = $elmTab.FindFirst($tree::Children, $cndT...
if($elmTabItem -ne $null){
$selTabItem = $elmTabItem.GetCurrentPattern($selptn)
$selTabItem.Select()
}
}
#データグリッド取得
if($elmPadWindow -ne $null){
$cndDataGrid = New-Object $pcdn($uiAuto::AutomationIdP...
$elmDataGrid = $elmPadWindow.FindFirst($tree::Subtree,...
}
#データ項目取得・選択
if($elmDataGrid -ne $null){
$icDataGrid = $elmDataGrid.GetCurrentPattern($icptn)
$elmDataItem = $icDataGrid.FindItemByProperty($null, $...
if($elmDataItem -ne $null){
$siDataItem = $elmDataItem.GetCurrentPattern($siptn)
$siDataItem.ScrollIntoView()
$selDataItem = $elmDataItem.GetCurrentPattern($selptn)
$selDataItem.Select()
}
}
#実行ボタン取得・押下
if($elmDataItem -ne $null){
$cndStartButton = New-Object $pcdn($uiAuto::Automation...
$elmStartButton = $elmDataItem.FindFirst($tree::Subtre...
if($elmStartButton -ne $null){
$ivkStartButton = $elmStartButton.GetCurrentPattern(...
$ivkStartButton.Invoke()
}
}
if($flgExit){
#フロー終了待ち
if($elmStartButton -ne $null){
do{
Start-Sleep -m 800
}while($elmStartButton.GetCurrentPropertyValue($uiAu...
}
#Power Automate for desktop終了
$winPadWindow = $elmPadWindow.GetCurrentPattern($wptn)
$winPadWindow.Close()
}
-Windows10の場合
さらに、以下のようなバッチを作成してそのショートカットを...
--kidou.bat
powershell -ExecutionPolicy Bypass -File "kidou.ps1"
***参考(ショートカット) [#u955592a]
-https://note.com/wynaut_952348/n/nc4b266cc666d
終了行:
*Power Automate Desktop [#jf259e71]
RIGHT:更新日&lastmod();
RIGHT:作成日:2024年11月7日
Power Automate DesktopはWindowsのソフトの起動、メニュー操...
**インストール [#aef24286]
-Windows11
既に入っているので、power automateでアプリを検索する
-Windows10
以下からPower Automate インストーラーをダウンロードしてイ...
--https://learn.microsoft.com/ja-jp/power-automate/deskto...
**起動 [#rf5b8b4a]
起動するとMSアカウントでログインを求められるので、ログイ...
起動すると以下のような画面にになる
&ref("./起動.png");
自分のフローに移動して、「新しいフロー」を選択する。
&ref("./起動2.png");
フローを作成する画面で、フロー名を入力して作成ボタンを押...
&ref("./起動3.png");
以下の作成画面が開く
&ref("./起動4.png");
左ペインのアクションから中央のペインのMainのペインにドラ...
&ref("./起動5.png");
**サンプル作成 [#ifcdf024]
***アクション内容 [#m4d7c926]
以下の手順でアプリケーションを起動させ、起動画面を表示さ...
+目的のアプリケーションを起動
+PADのコンソールを終了
+所定の画面が表示するまで待機
+メニューバーから目的のメニュ−を選択(階層になっているた...
+所定の画面が表示するまで待機
+矢印キーを2つ押して、Enterキーを入力
+テキストフィールドにファーカスをあてる
+テキストフィールドに文字列を入力して、Enterキーを入力
+二つ目のテキストフィールドにファーカスをあて文字列を入力...
***アクション内容入力 [#r0ec1d91]
-�.▲�ション「アプリケーションの実行」~
アプリケーションのフルパスを指定。~
&ref("./アプリケーションの実行.png");
-��PADでプログラムが起動してもPADコンソールがデスクトップ...
ALT+F4で終了させる
&ref("./コンソールの終了.png");
-�L榲�の画面の表示を待つ。そのWindowをUI要素で指定する。
&ref("./Window待機1.png");
-�こ�層メニューバーからメニューを選択。3階層なので、アクシ...
&ref("./メニュー選択.png");
-�Σ爾笄�を2つ入力してEnterを入力
&ref("./キー入力.png");
-�А銑� 同じアクションを2つ実行
&ref("./テキストボックス入力.png");
***メニューバーから選択をサーバアドレスが表示している個所...
-メニューバーから選択3つのアクションの無効化
&ref("./アクション無効化.png");
-サーバアドレス部を画像して認識させクリックする
&ref("./画像にマウスを移動してクリック.png");
&ref("./画像にマウスを移動してクリック2.png");
***保存画像の削除 [#yc6387a1]
&ref("./保存画像削除.png");
&ref("./保存画像削除2.png");
***ショートカット作成 [#tf91efdd]
-Windows11
PowerShellを作成して以下のようなスクリプトを作成してその...
-kidou.ps1
# Power Automate for desktopのフローを実行するPowerShell...
# @param [string] $flowName 実行するフロー名
# @param [bool] $flgExit PAD終了フラグ
#
# 動作確認:バージョン 2.40.157.24023 (インストーラー版)
#
Param(
[bool]$flgExit = $false
)
#Power Automate for desktop起動
Start-Process -FilePath "ms-powerautomate://"
#UI Automation
Add-Type -AssemblyName "UIAutomationClient"
Add-Type -AssemblyName "UIAutomationTypes"
$uiAuto = [System.Windows.Automation.AutomationElement]
$pcdn = [System.Windows.Automation.PropertyCondition]
$acdn = [System.Windows.Automation.AndCondition]
$tree = [System.Windows.Automation.TreeScope]
$iptn = [System.Windows.Automation.InvokePattern]::Pattern
$wptn = [System.Windows.Automation.WindowPattern]::Pattern
$icptn = [System.Windows.Automation.ItemContainerPattern...
$siptn = [System.Windows.Automation.ScrollItemPattern]::...
$selptn = [System.Windows.Automation.SelectionItemPatter...
$root = $uiAuto::RootElement
#Power Automate for desktopウィンドウ取得
$cndPadWindowId = New-Object $pcdn($uiAuto::AutomationId...
$cndPadWindowClassName = New-Object $pcdn($uiAuto::Class...
$cndPadWindow = New-Object $acdn($cndPadWindowId, $cndPa...
do{
Start-Sleep -m 200
$elmPadWindow = $root.FindFirst($tree::Children, $cndP...
}while($elmPadWindow -eq $null)
#タブ取得
$cndTab = New-Object $pcdn($uiAuto::AutomationIdProperty...
$elmTab = $elmPadWindow.FindFirst($tree::Subtree, $cndTab)
#タブ項目取得・選択
if($elmTab -ne $null){
$cndTabItem = New-Object $pcdn($uiAuto::AutomationIdPr...
$elmTabItem = $elmTab.FindFirst($tree::Children, $cndT...
if($elmTabItem -ne $null){
$selTabItem = $elmTabItem.GetCurrentPattern($selptn)
$selTabItem.Select()
}
}
#データグリッド取得
if($elmPadWindow -ne $null){
$cndDataGrid = New-Object $pcdn($uiAuto::AutomationIdP...
$elmDataGrid = $elmPadWindow.FindFirst($tree::Subtree,...
}
#データ項目取得・選択
if($elmDataGrid -ne $null){
$icDataGrid = $elmDataGrid.GetCurrentPattern($icptn)
$elmDataItem = $icDataGrid.FindItemByProperty($null, $...
if($elmDataItem -ne $null){
$siDataItem = $elmDataItem.GetCurrentPattern($siptn)
$siDataItem.ScrollIntoView()
$selDataItem = $elmDataItem.GetCurrentPattern($selptn)
$selDataItem.Select()
}
}
#実行ボタン取得・押下
if($elmDataItem -ne $null){
$cndStartButton = New-Object $pcdn($uiAuto::Automation...
$elmStartButton = $elmDataItem.FindFirst($tree::Subtre...
if($elmStartButton -ne $null){
$ivkStartButton = $elmStartButton.GetCurrentPattern(...
$ivkStartButton.Invoke()
}
}
if($flgExit){
#フロー終了待ち
if($elmStartButton -ne $null){
do{
Start-Sleep -m 800
}while($elmStartButton.GetCurrentPropertyValue($uiAu...
}
#Power Automate for desktop終了
$winPadWindow = $elmPadWindow.GetCurrentPattern($wptn)
$winPadWindow.Close()
}
-Windows10の場合
さらに、以下のようなバッチを作成してそのショートカットを...
--kidou.bat
powershell -ExecutionPolicy Bypass -File "kidou.ps1"
***参考(ショートカット) [#u955592a]
-https://note.com/wynaut_952348/n/nc4b266cc666d
ページ名: