From 891548f6b4caac13d16a119542716d0e06fdd6cd Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Sat, 9 Jan 2021 15:59:37 +0100 Subject: [PATCH] Added close-calculator.ps1 --- Data/scripts.csv | 1 + README.md | 3 ++- Scripts/close-calculator.ps1 | 9 +++++++++ Scripts/voice-control.ps1 | 4 +++- 4 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 Scripts/close-calculator.ps1 diff --git a/Data/scripts.csv b/Data/scripts.csv index ce6017d2..d0e5fe8c 100644 --- a/Data/scripts.csv +++ b/Data/scripts.csv @@ -3,6 +3,7 @@ check-ipv4-address.ps1, checks the given IPv4 address for validity check-mac-address.ps1, checks the given MAC address for validity check-xml-file.ps1, checks the given XML file for validity clone-repos.ps1, clones well-known Git repositories +close-calculator.ps1, closes the calculator program gracefully close-chrome.ps1, closes Google Chrome gracefully close-edge.ps1, closes Microsoft Edge gracefully close-file-explorer.ps1, closes Microsoft File Explorer gracefully diff --git a/README.md b/README.md index e020db83..e5125964 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ Collection of Useful PowerShell Scripts ======================================= -This repository contains 90+ useful and cross-platform PowerShell scripts - to be used by command-line interface (CLI), for remote control (RC), by context menu, by voice control, by automation software (e.g. Jenkins), or simply to learn PowerShell. +This repository contains 100+ useful and cross-platform PowerShell scripts - to be used by command-line interface (CLI), for remote control (RC), by context menu, by voice control, by automation software (e.g. Jenkins), or simply to learn PowerShell. List of Scripts --------------- @@ -11,6 +11,7 @@ The following PowerShell scripts can be found in the [Scripts/](Scripts/) subfol * [check-mac-address.ps1](Scripts/check-mac-address.ps1) - checks the given MAC address for validity * [check-xml-file.ps1](Scripts/check-xml-file.ps1) - checks the given XML file for validity * [clone-repos.ps1](Scripts/clone-repos.ps1) - clones well-known Git repositories +* [close-calculator.ps1](Scripts/close-calculator.ps1) - closes the calculator program gracefully * [close-chrome.ps1](Scripts/close-chrome.ps1) - closes Google Chrome gracefully * [close-edge.ps1](Scripts/close-edge.ps1) - closes Microsoft Edge gracefully * [close-file-explorer.ps1](Scripts/close-file-explorer.ps1) - closes Microsoft File Explorer gracefully diff --git a/Scripts/close-calculator.ps1 b/Scripts/close-calculator.ps1 new file mode 100644 index 00000000..d3fd887e --- /dev/null +++ b/Scripts/close-calculator.ps1 @@ -0,0 +1,9 @@ +#!/snap/bin/powershell +<# +.SYNTAX ./close-calculator.ps1 +.DESCRIPTION closes the calculator program gracefully +.LINK https://github.com/fleschutz/PowerShell +.NOTES Author: Markus Fleschutz / License: CC0 +#> + +./close-program "calc" "Calculator" diff --git a/Scripts/voice-control.ps1 b/Scripts/voice-control.ps1 index ed17a8d1..f41ae0f4 100755 --- a/Scripts/voice-control.ps1 +++ b/Scripts/voice-control.ps1 @@ -11,7 +11,7 @@ $PathToRepo = "$PSScriptRoot/.." try { write-output "Init speech recognition engine..." - $null = [Reflection.Assembly]::LoadWithPartialName("System.Speech") + [void][System.Reflection.Assembly]::LoadWithPartialName("System.Speech") $speechRecogEng = [System.Speech.Recognition.SpeechRecognitionEngine]::new() #$speechRecogEng.InitialSilenceTimeout = 15 $speechRecogEng.SetInputToDefaultAudioDevice() @@ -33,6 +33,8 @@ try { $grammar2.Append("exit") $speechRecogEng.LoadGrammar($grammar2) + write-output "NOTE: make sure the microphone volume is not too silent or too loud!" + write-output "Listening now ($Count voice commands)..." while ($true) { $recognized = $speechRecogEng.Recognize()