mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-04-24 19:08:27 +02:00
Update export-to-serenade.ps1
This commit is contained in:
parent
b24f938476
commit
678b26ab4f
@ -2,9 +2,15 @@
|
|||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Exports all scripts to Serenade for voice control
|
Exports all scripts to Serenade for voice control
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This script exports all PowerShell scripts to Serenade.ai for voice control.
|
This script exports all PowerShell scripts to Serenade to execute them by voice.
|
||||||
|
.PARAMETER WakeWord
|
||||||
|
Specifies the wakeword (none by default)
|
||||||
|
.PARAMETER FilePattern
|
||||||
|
Specifies the file pattern for the scripts ("$PSScriptRoot/*.ps1" by default)
|
||||||
|
.PARAMETER TargetFile
|
||||||
|
Specifies the target file ("$HOME/.serenade/scripts/PowerShell.js" by default)
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./export-to-serenade.ps1
|
PS> ./export-to-serenade.ps1 Computer
|
||||||
Exporting 264 scripts to C:\Users\Markus/.serenade/scripts/PowerShell.js...
|
Exporting 264 scripts to C:\Users\Markus/.serenade/scripts/PowerShell.js...
|
||||||
✔️ exported 264 PowerShell scripts to Serenade in 22 sec
|
✔️ exported 264 PowerShell scripts to Serenade in 22 sec
|
||||||
.NOTES
|
.NOTES
|
||||||
@ -15,7 +21,7 @@
|
|||||||
|
|
||||||
#requires -version 2
|
#requires -version 2
|
||||||
|
|
||||||
param([string]$FilePattern = "$PSScriptRoot/*.ps1", [string]$TargetFile = "$HOME/.serenade/scripts/PowerShell.js")
|
param([string]$WakeWord = "", [string]$FilePattern = "$PSScriptRoot/*.ps1", [string]$TargetFile = "$HOME/.serenade/scripts/PowerShell.js")
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$StopWatch = [system.diagnostics.stopwatch]::startNew()
|
$StopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||||
@ -23,12 +29,12 @@ try {
|
|||||||
$Scripts = Get-ChildItem "$FilePattern"
|
$Scripts = Get-ChildItem "$FilePattern"
|
||||||
"Exporting $($Scripts.Count) scripts to $TargetFile..."
|
"Exporting $($Scripts.Count) scripts to $TargetFile..."
|
||||||
|
|
||||||
"/* Exported by export-scripts2serenade.ps1 */" | Set-Content "$TargetFile"
|
"/* NOTE: This file has been generated automatically by export-to-serenade.ps1 */" | Set-Content "$TargetFile"
|
||||||
foreach ($Script in $Scripts) {
|
foreach ($Script in $Scripts) {
|
||||||
$ScriptName = $Script.basename
|
$ScriptName = $Script.basename
|
||||||
$Keyword = $ScriptName -replace "-"," "
|
$Keyword = $ScriptName -replace "-"," "
|
||||||
"" | Add-Content "$TargetFile"
|
"" | Add-Content "$TargetFile"
|
||||||
"serenade.global().command(`"$Keyword`", async (api) => {" | Add-Content "$TargetFile"
|
"serenade.global().command(`"$WakeWord $Keyword`", async (api) => {" | Add-Content "$TargetFile"
|
||||||
"await api.focusOrLaunchApplication(`"terminal`");" | Add-Content "$TargetFile"
|
"await api.focusOrLaunchApplication(`"terminal`");" | Add-Content "$TargetFile"
|
||||||
"await api.typeText(`"$ScriptName.ps1`");" | Add-Content "$TargetFile"
|
"await api.typeText(`"$ScriptName.ps1`");" | Add-Content "$TargetFile"
|
||||||
"await api.pressKey(`"return`");" | Add-Content "$TargetFile"
|
"await api.pressKey(`"return`");" | Add-Content "$TargetFile"
|
||||||
|
Loading…
Reference in New Issue
Block a user