Added close-calculator.ps1

This commit is contained in:
Markus Fleschutz 2021-01-09 15:59:37 +01:00
parent e0d576d662
commit 891548f6b4
4 changed files with 15 additions and 2 deletions

View File

@ -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

1 Filename Description
3 check-mac-address.ps1 checks the given MAC address for validity
4 check-xml-file.ps1 checks the given XML file for validity
5 clone-repos.ps1 clones well-known Git repositories
6 close-calculator.ps1 closes the calculator program gracefully
7 close-chrome.ps1 closes Google Chrome gracefully
8 close-edge.ps1 closes Microsoft Edge gracefully
9 close-file-explorer.ps1 closes Microsoft File Explorer gracefully

View File

@ -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

View File

@ -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"

View File

@ -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()