From 6f1b4bbcd757a5ebd32db5efe9784130395463e8 Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Tue, 23 Nov 2021 22:03:30 +0100 Subject: [PATCH] Add close-notepad-app.ps1 and minimize-notepad-app.ps1 --- Scripts/close-notepad-app.ps1 | 19 +++++++++++++++++++ Scripts/minimize-notepad-app.ps1 | 15 +++++++++++++++ ...{open-notepad.ps1 => open-notepad-app.ps1} | 4 ++-- 3 files changed, 36 insertions(+), 2 deletions(-) create mode 100755 Scripts/close-notepad-app.ps1 create mode 100755 Scripts/minimize-notepad-app.ps1 rename Scripts/{open-notepad.ps1 => open-notepad-app.ps1} (87%) diff --git a/Scripts/close-notepad-app.ps1 b/Scripts/close-notepad-app.ps1 new file mode 100755 index 00000000..b31f021c --- /dev/null +++ b/Scripts/close-notepad-app.ps1 @@ -0,0 +1,19 @@ +<# +.SYNOPSIS + Closes the Notepad app +.DESCRIPTION + This script closes the Notepad application gracefully. +.EXAMPLE + PS> ./close-notepad-app +.NOTES + Author: Markus Fleschutz · License: CC0 +.LINK + https://github.com/fleschutz/PowerShell +#> + +TaskKill /im Notepad +if ($lastExitCode -ne "0") { + & "$PSScriptRoot/speak-english.ps1" "Sorry, Notepad is already closed." + exit 1 +} +exit 0 # success diff --git a/Scripts/minimize-notepad-app.ps1 b/Scripts/minimize-notepad-app.ps1 new file mode 100755 index 00000000..4ca125ce --- /dev/null +++ b/Scripts/minimize-notepad-app.ps1 @@ -0,0 +1,15 @@ +<# +.SYNOPSIS + Minimizes the Notepad app +.DESCRIPTION + This script minimizes the Notepad application. +.EXAMPLE + PS> ./minimize-notepad-app +.NOTES + Author: Markus Fleschutz · License: CC0 +.LINK + https://github.com/fleschutz/PowerShell +#> + +get-process Notepad | Set-WindowStyle -Style Minimize +exit 0 # success diff --git a/Scripts/open-notepad.ps1 b/Scripts/open-notepad-app.ps1 similarity index 87% rename from Scripts/open-notepad.ps1 rename to Scripts/open-notepad-app.ps1 index ba900d98..ce20c236 100755 --- a/Scripts/open-notepad.ps1 +++ b/Scripts/open-notepad-app.ps1 @@ -1,10 +1,10 @@ <# .SYNOPSIS - Starts Notepad + Launches the Notepad app .DESCRIPTION This script launches the Notepad application. .EXAMPLE - PS> ./open-notepad + PS> ./open-notepad-app .NOTES Author: Markus Fleschutz · License: CC0 .LINK