Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement #44

Merged
merged 4 commits into from
May 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions itt.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8013,7 +8013,10 @@ function Invoke-Button {
Switch -Wildcard ($debug){

"installBtn" {Invoke-Install $debug}

"applyBtn" {Invoke-ApplyTweaks $debug}


"taps" {ChangeTap $debug}
"category" {FilterByCat($sync.category.SelectedItem.Content) $debug}
"searchInput" {Search; $sync['window'].FindName('category').SelectedIndex = 0; $sync['window'].FindName('apps').IsSelected = $true; $debug }
Expand Down Expand Up @@ -8131,6 +8134,10 @@ function ShowSelectedItems {
function Invoke-Install
{

$sync['window'].Dispatcher.Invoke([Action]{
$sync.installBtn.IsEnabled = $false
})

if($sync.ProcessRunning)
{
$msg = "Please wait there is a process in the background."
Expand Down Expand Up @@ -8467,6 +8474,11 @@ https://t.me/emadadel4
}
else
{
$sync['window'].Dispatcher.Invoke([Action]{
$sync.installBtn.IsEnabled = $true
})


# Uncheck all checkboxes in $list
$sync.AppsListView.Dispatcher.Invoke([Action]{
foreach ($item in $sync.AppsListView.Items)
Expand Down Expand Up @@ -8497,6 +8509,10 @@ https://t.me/emadadel4
else
{
[System.Windows.MessageBox]::Show("Choose at least one program", "ITT | Emad Adel", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Information)

$sync['window'].Dispatcher.Invoke([Action]{
$sync.installBtn.IsEnabled = $true
})
}
}

Expand Down
131 changes: 62 additions & 69 deletions newTweak.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -38,80 +38,73 @@ if($userInput -eq "Registry")
{

$TweakName = Read-Host "Enter Tweak Name"

$description = Read-Host "Enter Tweak description"

$validTypes = @{

1 = "delete"
2 = "modifying"
}

# Prompt user to choose category
# Read multiple AppxPackage Names
$Names = @()
# Read multiple AppxPackage Names
do {
Write-Host "This will do?"
foreach ($key in $validTypes.Keys | Sort-Object) {
Write-Host "$key - $($validTypes[$key])"
}
$choice = Read-Host "Enter the number corresponding to the type"
if ([int]$choice -in $validTypes.Keys) {
$RegistryType = $validTypes[[int]$choice]
} else {
Write-Host "Invalid choice. Please select a valid option."
}
} until ([int]$choice -in $validTypes.Keys)

$Path = Read-Host "Enter Reg Path"
$Name = Read-Host "Enter Value Name"


$KeyType = @{

1 = "DWord"
2 = "Qword"
3 = "Binary"
4 = "SZ"
5 = "EXPAND_SZ"
6 = "LINK"
7 = "MULTI_SZ"
8 = "NONE"
9 = "QWORD_LITTLE_ENDIAN"
}

# Prompt user to choose KeyType
do {
Write-Host "What is the Key type"
foreach ($key in $KeyType.Keys | Sort-Object) {
Write-Host "$key - $($KeyType[$key])"
}
$choice = Read-Host "Enter the number corresponding to the Key Type"
if ([int]$choice -in $KeyType.Keys) {
$Type = $KeyType[[int]$choice]
} else {
Write-Host "Invalid choice. Please select a valid option."
}
} until ([int]$choice -in $KeyType.Keys)

$Path = Read-Host "Enter Registry, Example: HKLM:\SOFTWARE\Policies\Microsoft\Windows\OneDrive"
$Path = $Path -replace '\\', '\\'
$Name = Read-Host "Enter Reg Name"

$KeyType = @{
$Value = Read-Host "Enter Value"
$defaultValue = Read-Host "Enter default Value"

1 = "DWord"
2 = "Qword"
3 = "Binary"
4 = "SZ"
5 = "EXPAND_SZ"
6 = "LINK"
7 = "MULTI_SZ"
8 = "NONE"
9 = "QWORD_LITTLE_ENDIAN"
}
$Names += $Name

# Prompt user to choose KeyType
do {
Write-Host "What is the Key type"
foreach ($key in $KeyType.Keys | Sort-Object) {
Write-Host "$key - $($KeyType[$key])"
}
$choice = Read-Host "Enter the number corresponding to the Key Type"
if ([int]$choice -in $validType.Keys) {
$Type = $KeyType[[int]$choice]
} else {
Write-Host "Invalid choice. Please select a valid option."
}
} until ([int]$choice -in $KeyType.Keys)


$Value = Read-Host "Enter Registry value"
$continue = Read-Host "Do you want to add another Path? (y/n)"
} while ($continue -eq "y")

$defaultValue = Read-Host "Enter Registry default Value"
if ($defaultValue -eq "") { $defaultValue = "1" } # Set default value 1

# Define the data
$data = @{
"name" = $TweakName
"description" = $description
"check" = "false"
"type" = $RegistryType
"type" = "AppxPackage"
"refresh" = "false"
"$userInput" = @(
@{
"Path" = $Path
"Name" = $Name
"Type" = $Type
"Value" = $Value
"defaultValue" = $defaultValue
$Names | ForEach-Object {
@{
"Path" = $Path
"Name" = $Name
"Type" = $Type
"Value" = $Value
"defaultValue" = $defaultValue

} | Select-Object Path, Name, Type, Value, defaultValue
}
)
}
Expand All @@ -123,20 +116,16 @@ $jsonString = @"
"description": "$($data["description"])",
"check": "$($data["check"])",
"type": "$($data["type"])",
"$userInput": [
{
"Path": "$($data["$userInput"][0]["Path"])",
"Name": "$($data["$userInput"][0]["Name"])",
"Type": "$($data["$userInput"][0]["Type"])",
"Value": "$($data["$userInput"][0]["Value"])",
"defaultValue": "$($data["$userInput"][0]["defaultValue"])",
}
]
"refresh": "$($data["refresh"])",
"$userInput": $($data["$userInput"] | ConvertTo-Json -Depth 100)
}
"@

# Read existing JSON file
$existingJson = Get-Content -Path "./Assets/Database/Tweaks.json" | ConvertFrom-Json
$existingJson = Get-Content -Path "./Assets/Database/Tweaks.json" -Raw | ConvertFrom-Json -ErrorAction SilentlyContinue
if (!$existingJson) {
$existingJson = @()
}

# Append new data to existing JSON
$existingJson += $jsonString | ConvertFrom-Json
Expand All @@ -146,10 +135,8 @@ $updatedJson = $existingJson | ConvertTo-Json -Depth 100

# Output to file
$updatedJson | Out-File -FilePath "./Assets/Database/Tweaks.json" -Encoding utf8

Write-Host "Added successfully, Don't forget to build and test it before commit" -ForegroundColor Green


}
#===========================================================================
#endregion Registry
Expand Down Expand Up @@ -181,6 +168,7 @@ $data = @{
"description" = $description
"check" = "false"
"type" = "AppxPackage"
"refresh" = "false"
"$userInput" = @(
$Names | ForEach-Object {
@{
Expand All @@ -197,6 +185,7 @@ $jsonString = @"
"description": "$($data["description"])",
"check": "$($data["check"])",
"type": "$($data["type"])",
"refresh": "$($data["refresh"])",
"$userInput": $($data["$userInput"] | ConvertTo-Json -Depth 100)
}
"@
Expand Down Expand Up @@ -242,6 +231,7 @@ $data = @{
"description" = $description
"check" = "false"
"type" = "command"
"refresh" = "false"
"$userInput" = @(
@{
"run" = $cmd
Expand All @@ -257,6 +247,7 @@ $jsonString = @"
"description": "$($data["description"])",
"check": "$($data["check"])",
"type": "$($data["type"])",
"refresh": "$($data["refresh"])",
"$userInput": [
{
"run": "$($data["$userInput"][0]["run"])",
Expand Down Expand Up @@ -318,6 +309,7 @@ $data = [Ordered]@{
"description" = $description
"check" = "false"
"type" = "service"
"refresh" = "false"
"$userInput" = @(
$Names | ForEach-Object {
[Ordered]@{
Expand All @@ -336,6 +328,7 @@ $jsonString = @"
"description": "$($data["description"])",
"check": "$($data["check"])",
"type": "$($data["type"])",
"refresh": "$($data["refresh"])",
"$userInput": $($data["$userInput"] | ConvertTo-Json -Depth 100)
}
"@
Expand Down
Loading