From 94555e9dd027efa517f7a0ebfe822508a8eae6c5 Mon Sep 17 00:00:00 2001 From: DeveloperDurp <74198206+DeveloperDurp@users.noreply.github.com> Date: Sat, 26 Jun 2021 12:11:10 -0500 Subject: [PATCH] Update KeyPresser.ps1 added config file --- KeyPresser.ps1 | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/KeyPresser.ps1 b/KeyPresser.ps1 index d73bfe2..0c1b237 100644 --- a/KeyPresser.ps1 +++ b/KeyPresser.ps1 @@ -1,6 +1,30 @@ #region Header - $Version = "1.0.4" + $Version = "1.0.5" + + $appdatapath = "$env:APPDATA\DeveloperDurp\KeyPresser" + $configpath = "$appdatapath\config.json" + + #Check for config file + $KeypresserPath = Test-Path $appdatapath + if($KeypresserPath -eq $false){ + + New-Item -Path $appdatapath -ItemType Directory + + } + + #checking for config file + $configfile = Test-Path $configpath + if($configfile -eq $false){ + + $json = @{ + + text = "1,2,3,4" + client ="sro_client" + delay ="150" + } + + }else{$json = Get-Content $configpath | ConvertFrom-Json} #Dependencies [Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | Out-Null @@ -90,6 +114,7 @@ $KeysTextBox = New-Object 'System.Windows.Forms.TextBox' $KeysTextBox.Location = New-Object System.Drawing.Point(5,25) $KeysTextBox.Width = '425' + $KeysTextBox.text = $json.text $sync["KeysTextBox"] = $KeysTextBox $form.controls.add($KeysTextBox) @@ -98,6 +123,14 @@ $KeysButton.text = "Start" $KeysButton.add_click({ + $json = @{ + + text = $sync["KeysTextBox"].text + delay = $sync["delayTextBox"].text + client = $sync["clienttextbox"].text + + } | ConvertTo-Json | Out-File $configpath + if ($KeysButton.text -ne "Stop"){ $KeysButton.text = "Stop" $sync["x"] = 1 @@ -120,7 +153,7 @@ $delayTextBox = New-Object 'System.Windows.Forms.TextBox' $delayTextBox.Location = New-Object System.Drawing.Point(195,45) $delayTextBox.Width = '30' - $delayTextBox.text = "150" + $delayTextBox.text = $json.delay $sync["delayTextBox"] = $delayTextBox $form.controls.add($delayTextBox) @@ -133,7 +166,7 @@ $clientTextBox = New-Object 'System.Windows.Forms.TextBox' $clientTextBox.Location = New-Object System.Drawing.Point(305,45) $clientTextBox.Width = '100' - $clientTextBox.text = "sro_client" + $clientTextBox.text = $json.client $sync["clienttextbox"] = $clientTextBox $form.controls.add($clientTextBox)