Skip to content

Instantly share code, notes, and snippets.

View kinuasa's full-sized avatar

@kinuasa kinuasa

View GitHub Profile
@kinuasa
kinuasa / FillingOutPdfFormsWithPdfSharp.ps1
Created May 2, 2024 05:17
PdfSharpを使ってPDFフォームに入力するPowerShellスクリプトです。 関連Webサイト:https://powerusers.microsoft.com/t5/Power-Automate-Desktop/Entering-text-into-a-specific-field-for-a-pdf/td-p/2733417
[void][Reflection.Assembly]::LoadFile("C:\System\Lib\PdfSharp.dll")
$doc = [PdfSharp.Pdf.IO.PdfReader]::Open("C:\Test\PDF\SampleField.pdf", [PdfSharp.Pdf.IO.PdfDocumentOpenMode]::Modify)
$form = $doc.AcroForm
if($form.Elements.ContainsKey("/NeedAppearances") -eq $true){
$form.Elements["/NeedAppearances"] = [PdfSharp.Pdf.PdfBoolean]::True
}else{
$form.Elements.Add("/NeedAppearances", [PdfSharp.Pdf.PdfBoolean]::True)
}
$fields = $form.Fields
$fields["Name"].Value = [PdfSharp.Pdf.PdfString]::new("foo bar")
SET WindowsApplicationDriverPath TO $'''\"C:\\Program Files (x86)\\Windows Application Driver\\WinAppDriver.exe\"'''
SET AppId TO $'''mspaint.exe'''
SET WindowsApplicationDriverUrl TO $'''http://127.0.0.1:4723'''
SET ImageFilePath TO $'''\"C:\\Test\\Image\\TEST.png\"'''
System.RunApplication.RunApplication ApplicationPath: $'''cmd''' CommandLineArguments: $'''/k %WindowsApplicationDriverPath%''' WorkingDirectory: $'''C:\\''' WindowStyle: System.ProcessWindowStyle.Normal ProcessId=> AppProcessId
Web.InvokeWebService.InvokeWebService Url: $'''%WindowsApplicationDriverUrl%/session''' Method: Web.Method.Post Accept: $'''application/json''' ContentType: $'''application/json''' RequestBody: $'''{\"desiredCapabilities\":{\"app\":\"%AppId%\",\"deviceName\":\"WindowsPC\",\"platformName\":\"Windows\"}}''' ConnectionTimeout: 30 FollowRedirection: True ClearCookies: False FailOnErrorStatus: False EncodeRequestBody: False UserAgent: $'''Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.21) Gecko/20100312 Firefox/3.
SET WindowsApplicationDriverPath TO $'''\"C:\\Program Files (x86)\\Windows Application Driver\\WinAppDriver.exe\"'''
SET AppId TO $'''Microsoft.WindowsCalculator_8wekyb3d8bbwe!App'''
SET WindowsApplicationDriverUrl TO $'''http://127.0.0.1:4723'''
System.RunApplication.RunApplication ApplicationPath: $'''cmd''' CommandLineArguments: $'''/k %WindowsApplicationDriverPath%''' WorkingDirectory: $'''C:\\''' WindowStyle: System.ProcessWindowStyle.Normal ProcessId=> AppProcessId
Web.InvokeWebService.InvokeWebService Url: $'''%WindowsApplicationDriverUrl%/session''' Method: Web.Method.Post Accept: $'''application/json''' ContentType: $'''application/json''' RequestBody: $'''{\"desiredCapabilities\":{\"app\":\"%AppId%\",\"deviceName\":\"WindowsPC\",\"platformName\":\"Windows\"}}''' ConnectionTimeout: 30 FollowRedirection: True ClearCookies: False FailOnErrorStatus: False EncodeRequestBody: False UserAgent: $'''Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.21) Gecko/20100312 Firefox/3.6''' Encoding: Web.Encod
@kinuasa
kinuasa / PowerAutomateDesktopActions_English.md
Last active April 4, 2024 01:49
List of actions for Power Automate for desktop - Japanese version: https://www.ka-net.org/blog/?p=13749 , English version: https://www.ka-net.org/blog/?p=15986

List of actions for Power Automate for desktop

Version: 2.43.00161.24092 (Store app)

Group1 Group2 Group3 Actions Description
Variables Data table Create new data table Creates a new data table variable
Variables Data table Insert row into data table Inserts a row at the end or before a specific index value
Variables Data table Find or replace in data table Finds and/or replaces data table values
Variables Data table Update data table item Update a data table row item on a defined column
Variables Data table Delete row from data table Delete a data table row at the corresponding row index
@kinuasa
kinuasa / PowerAutomateDesktopActions.md
Last active April 4, 2024 00:55
Power Automate for desktop アクション一覧 日本語版:https://www.ka-net.org/blog/?p=13749 , 英語版:https://www.ka-net.org/blog/?p=15986

Power Automate for desktop アクション一覧

バージョン 2.43.00161.24092 (ストアアプリ版)

アクショングループ1 アクショングループ2 アクショングループ3 アクション 説明
変数 データ テーブル 新しいデータ テーブルを作成する 新しいデータ テーブル変数を作成する
変数 データ テーブル 行をデータ テーブルに挿入する 行を末尾または指定されたインデックス値の前に挿入する
変数 データ テーブル データ テーブル内で検索または置換する データ テーブルの値を検索または置換する
変数 データ テーブル データ テーブル項目を更新する 定義された列でデータ テーブル行の項目を更新する
変数 データ テーブル データ テーブルから行を削除する 行インデックスで指定されたデータ テーブル行を削除する
@kinuasa
kinuasa / StartPADFlow.ps1
Last active April 3, 2024 02:07
Run a Power Automate for desktop Flow using PowerShell Script. refer to: https://www.ka-net.org/blog/?p=13647
# Power Automate for desktopのフローを実行するPowerShellスクリプト
# @param [string] $flowName 実行するフロー名
# @param [bool] $flgExit PAD終了フラグ
#
# 動作確認:バージョン 2.40.157.24023 (インストーラー版)
#
Param(
[parameter(mandatory=$true)][string]$flowName,
[bool]$flgExit = $false
@kinuasa
kinuasa / GetPadFlowName.ps1
Last active March 14, 2024 06:50
実行中のPower Automate for desktop(PAD)フロー名を取得するスクリプトです。関連記事:https://www.ka-net.org/blog/?p=14429
# 実行中のPower Automate for desktop(PAD)フロー名を取得するスクリプト
# ※複数のフローが同時に実行されている場合([PAD.Designer.exe][PAD.Robot.exe]が複数実行されている場合)については考慮していません。
#
$procPADDesigner = Get-WmiObject -Class Win32_Process | Where-Object {$_.Name -eq "PAD.Designer.exe"}
if($procPADDesigner){
#デザイナーから実行している場合
#[PAD.Designer.exe]のコマンドライン[processname]の値をURLデコードしてフロー名取得
$regexPADDesigner = [regex]::Match($procPADDesigner.CommandLine.ToLower(), "processname=.*?&")
if($regexPADDesigner.Success){
Add-Type -AssemblyName "System.Web"
@kinuasa
kinuasa / 指定した日時から直近の平日を求めるPower Automate for desktopフロー.robin
Created February 29, 2024 06:56
指定した日時から直近の平日を求めるPower Automate for desktopフロー(動作確認:バージョン 2.41 ) 関連Webサイト:https://powerusers.microsoft.com/t5/Power-Automate-Desktop/Determining-the-date-of-the-most-recent-weekday/td-p/2630429
/# ☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
祝日一覧をデータテーブルに格納
※Google Calendar APIのような祝日を取得するAPIを利用しても可
☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★#/
SET HolidayTable TO { ^['Date', 'Summary'], ['2024-01-01', '元日'], ['2024-01-08', '成人の日'], ['2024-02-11', '建国記念の日'], ['2024-02-12', '建国記念の日 振替休日'], ['2024-02-23', '天皇誕生日'], ['2024-03-20', '春分の日'], ['2024-04-29', '昭和の日'], ['2024-05-03', '憲法記念日'], ['2024-05-04', 'みどりの日'], ['2024-05-05', 'こどもの日'], ['2024-05-06', 'こどもの日 振替休日'], ['2024-07-15', '海の日'], ['2024-08-11', '山の日'], ['2024-08-12', '休日 山の日'], ['2024-09-16', '敬老の日'], ['2024-09-22', '秋分の日'], ['2024-09-23', '秋分の日 振替休日'], ['2024-10-14', 'スポーツの日'], ['2024-11-03', '文化の日'], ['2024-11-04', '文化の日 振替休日'], ['2024-11-23', '勤労感謝の日'] }
DateTime.GetCurrentDateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateAndTime CurrentDateTime=> CurrentDateTime
# テスト用に日時設定
Text.ConvertTextToDateTime.ToDateTime Text: $'''2024/5/8''' DateTime=> CurrentDateTime
/# ☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
指定日の2日前から14日間さかのぼって祝休日かどうかの判定を行う
@kinuasa
kinuasa / kintoneにアップロードした添付ファイルを一括でダウンロードすフロー.robin
Created January 31, 2024 06:00
kintoneにアップロードした添付ファイルを一括でダウンロードするPower Automate for desktopフロー(動作確認:バージョン 2.40 )
/# ☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
APIトークンなどの変数設定
☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★#/
SET APIToken TO $'''(APIトークン)'''
SET SubDomain TO $'''(サブドメイン)'''
Text.FromNumber Number: 6 DecimalPlaces: 0 UseThousandsSeparator: False FormattedNumber=> AppID
SET SaveFolderPath TO $'''C:\\Test\\kintone\\Files'''
/# ☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
添付ファイルフィールドのフィールドコードをリストに設定
☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★#/
@kinuasa
kinuasa / PDFフォームへのデータ入力を自動化するPower Automate for desktopフロー.robin
Last active December 20, 2023 04:20
PDFtkを使ってPDFフォームへのデータ入力を自動化するPower Automate for desktopフロー(動作確認:バージョン 2.39 ) 関連Webサイト:https://note.com/kinuasa/n/nc93aefd55e87
SET PdfFolderPath TO $'''C:\\Test\\受領書'''
/# ☆★☆★☆★☆★☆★☆★☆★☆★☆★☆
リストファイル読み込み
☆★☆★☆★☆★☆★☆★☆★☆★☆★☆#/
Excel.LaunchExcel.LaunchAndOpenUnderExistingProcess Path: $'''%PdfFolderPath%\\受領書発行リスト.xlsx''' Visible: True ReadOnly: True Instance=> ExcelInstance
Excel.SetActiveWorksheet.ActivateWorksheetByName Instance: ExcelInstance Name: $'''受領書発行リスト'''
Excel.GetFirstFreeColumnRow Instance: ExcelInstance FirstFreeColumn=> FirstFreeColumn FirstFreeRow=> FirstFreeRow
Excel.ReadFromExcel.ReadCells Instance: ExcelInstance StartColumn: $'''A''' StartRow: 1 EndColumn: FirstFreeColumn - 1 EndRow: FirstFreeRow - 1 ReadAsText: True FirstLineIsHeader: True RangeValue=> ExcelData
Excel.CloseExcel.Close Instance: ExcelInstance
/# ☆★☆★☆★☆★☆★☆★☆★☆★☆★☆