-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtouchy.ps1
More file actions
77 lines (70 loc) · 3.23 KB
/
Copy pathtouchy.ps1
File metadata and controls
77 lines (70 loc) · 3.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# Ascii Art
# Define the one-liners
$oneLiners = @(
{ Get-PnpDevice | Where-Object {$_.FriendlyName -like '*touch screen*'} | Enable-PnpDevice -Confirm:$false },
{ Get-PnpDevice | Where-Object {$_.FriendlyName -like '*touch screen*'} | Disable-PnpDevice -Confirm:$false },
{ Get-PnpDevice | Where-Object {$_.FriendlyName -like '*pen*'} | Enable-PnpDevice -Confirm:$false },
{ Get-PnpDevice | Where-Object {$_.FriendlyName -like '*pen*'} | Disable-PnpDevice -Confirm:$false },
{
Get-PnpDevice | Where-Object {$_.FriendlyName -like '*touch screen*' -or $_.FriendlyName -like '*pen*'} |
Enable-PnpDevice -Confirm:$false
},
{
Get-PnpDevice | Where-Object {$_.FriendlyName -like '*touch screen*' -or $_.FriendlyName -like '*pen*'} |
Disable-PnpDevice -Confirm:$false
}
)
# Display the header
function Show-Header {
Write-Host " " -BackgroundColor Yellow -ForegroundColor Black
Write-Host " Touchy - Touch and Pen Controller " -BackgroundColor Yellow -ForegroundColor Black
Write-Host " Version 1.2.0 - Pixelchemist " -BackgroundColor Yellow -ForegroundColor DarkGray
Write-Host " " -BackgroundColor Yellow -ForegroundColor Black
}
# Display the menu
function Show-Menu {
Write-Host "`nSelect one of the following options:" -ForegroundColor White
Write-Host "1. Enable Touch Screen" -ForegroundColor Cyan
Write-Host "2. Disable Touch Screen" -ForegroundColor Red
Write-Host "3. Enable Pen Input" -ForegroundColor Green
Write-Host "4. Disable Pen Input" -ForegroundColor Yellow
Write-Host "5. Enable Both (Touch Screen & Pen)" -ForegroundColor Cyan
Write-Host "6. Disable Both (Touch Screen & Pen)" -ForegroundColor Red
Write-Host "7. Quit" -ForegroundColor Magenta
Write-Host "`n" -ForegroundColor White
}
# Execute the selected action
function Execute-Selection {
param ([int]$selection)
if ($selection -ge 1 -and $selection -le $oneLiners.Count) {
$scriptBlock = $oneLiners[$selection - 1]
$encodedCommand = [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($scriptBlock.ToString()))
Start-Process powershell.exe -Verb RunAs -ArgumentList "-NoProfile -ExecutionPolicy Bypass -EncodedCommand $encodedCommand"
Write-Host "`nExecuting the selected command as an administrator..." -ForegroundColor White
}
elseif ($selection -eq 7) {
Write-Host "`nExiting Touchy. Goodbye!" -ForegroundColor Magenta
exit
}
else {
Write-Host "`nInvalid selection. Please choose a valid option." -ForegroundColor Red
}
}
# Main loop
while ($true) {
Clear-Host
Show-Header
Show-Menu
$selection = Read-Host "Enter the option number"
# Validate the input
if ([int]::TryParse($selection, [ref]$null)) {
# Convert to integer after validation
$selection = [int]$selection
Execute-Selection -selection $selection
}
else {
Write-Host "`nInvalid input. Please enter a number corresponding to the menu options." -ForegroundColor Red
}
Write-Host "`nPress any key to continue..." -ForegroundColor White
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}