diff --git a/Docs/Example scripts/Microsoft.PowerShell_profile.ps1 b/Docs/Example scripts/Microsoft.PowerShell_profile.ps1 new file mode 100644 index 0000000..7a27c2d --- /dev/null +++ b/Docs/Example scripts/Microsoft.PowerShell_profile.ps1 @@ -0,0 +1,45 @@ +function getBacklight() +{ + $value = & 'C:\Program Files\LGTV Companion\LGTVcli.exe' -ok backlight -get_system_settings picture [`\`"backlight`\`"] + Write-Host "Backlight is set to $value" +} + +function setBacklight([int]$value) +{ + & 'C:\Program Files\LGTV Companion\LGTVcli.exe' -backlight "$value" | Out-Null + Write-Host "Backlight set to $value" +} + +function volumeUp() +{ + & 'C:\Program Files\LGTV Companion\LGTVcli.exe' -request com.webos.service.audio/master/volumeUp | Out-Null +} + +function volumeDown() +{ + & 'C:\Program Files\LGTV Companion\LGTVcli.exe' -request com.webos.service.audio/master/volumeDown | Out-Null +} + + +function getVolume() +{ + $jsonObject = (& 'C:\Program Files\LGTV Companion\LGTVcli.exe' -request com.webos.service.audio/master/getVolume)|ConvertFrom-json + $volume=$jsonObject.Device1.payload.volumeStatus.volume + Write-Host "Volume is set to $volume" +} + +function setVolume([int]$value) +{ + & 'C:\Program Files\LGTV Companion\LGTVcli.exe' -request_with_param com.webos.service.audio/master/setVolume "{\`"volume\`":$value}" | Out-Null + Write-Host "Volume set to $value" +} + +function setHDMI([int]$value) +{ + if ($value -In 1..4) { + & 'C:\Program Files\LGTV Companion\LGTVcli.exe' -setHdmi "$value" | Out-Null + Write-Host "HDMI is set to $value" + } else { + Write-Host "HDMI can only be set between 1-4!" + } +} diff --git a/Docs/Powershell functions.md b/Docs/Powershell functions.md new file mode 100644 index 0000000..b895364 --- /dev/null +++ b/Docs/Powershell functions.md @@ -0,0 +1,63 @@ +# Powershell example functions + +Following functions are definedin the file [Microsoft.PowerShell_profile.ps1](./Example%20scripts/Microsoft.PowerShell_profile.ps1) + +- getBacklight +- setBacklight [0-100] +- getVolume +- setVolume [0-100] +- volumeUp +- volumeDown +- setHDMI [1-4] + +If you don't have this file already, just make a folder called `WindowsPowerShell` in your `C:\Users\\Documents` and copy the file [Microsoft.PowerShell_profile.ps1](./Example%20scripts/Microsoft.PowerShell_profile.ps1) into it. The functions will be then usable in the every new powershell session. + +# Functions + +```Powershell +function getBacklight() +{ + $value = & 'C:\Program Files\LGTV Companion\LGTVcli.exe' -ok backlight -get_system_settings picture [`\`"backlight`\`"] + Write-Host "Backlight is set to $value" +} + +function setBacklight([int]$value) +{ + & 'C:\Program Files\LGTV Companion\LGTVcli.exe' -backlight "$value" | Out-Null + Write-Host "Backlight set to $value" +} + +function volumeUp() +{ + & 'C:\Program Files\LGTV Companion\LGTVcli.exe' -request com.webos.service.audio/master/volumeUp | Out-Null +} + +function volumeDown() +{ + & 'C:\Program Files\LGTV Companion\LGTVcli.exe' -request com.webos.service.audio/master/volumeDown | Out-Null +} + + +function getVolume() +{ + $jsonObject = (& 'C:\Program Files\LGTV Companion\LGTVcli.exe' -request com.webos.service.audio/master/getVolume)|ConvertFrom-json + $volume=$jsonObject.Device1.payload.volumeStatus.volume + Write-Host "Volume is set to $volume" +} + +function setVolume([int]$value) +{ + & 'C:\Program Files\LGTV Companion\LGTVcli.exe' -request_with_param com.webos.service.audio/master/setVolume "{\`"volume\`":$value}" | Out-Null + Write-Host "Volume set to $value" +} + +function setHDMI([int]$value) +{ + if ($value -In 1..4) { + & 'C:\Program Files\LGTV Companion\LGTVcli.exe' -setHdmi "$value" | Out-Null + Write-Host "HDMI is set to $value" + } else { + Write-Host "HDMI can only be set between 1-4!" + } +} +``` \ No newline at end of file