From b653f2242d8a58fa85ab2a16beb030a8b2dce893 Mon Sep 17 00:00:00 2001 From: 0xFurtiv <84947139+0xFurtiv@users.noreply.github.com> Date: Wed, 10 Jul 2024 12:53:36 -0700 Subject: [PATCH 1/8] Add autorun files --- autorun.ps1 | 16 ++++++++++++++++ install-autorun.ps1 | 27 +++++++++++++++++++++++++++ uninstall-autorun.ps1 | 10 ++++++++++ 3 files changed, 53 insertions(+) create mode 100644 autorun.ps1 create mode 100644 install-autorun.ps1 create mode 100644 uninstall-autorun.ps1 diff --git a/autorun.ps1 b/autorun.ps1 new file mode 100644 index 00000000..1cbe75d4 --- /dev/null +++ b/autorun.ps1 @@ -0,0 +1,16 @@ +param ( + [ValidateNotNullOrEmpty()][string]$SettingsFile = "$(Join-Path $Env:LOCALAPPDATA (Join-Path 'Raw Accel' 'settings.json'))" +) + +$SettingsFile = Convert-Path($SettingsFile) +$settingsDirectory = [IO.Path]::GetDirectoryName($SettingsFile) +$settingsFileName = [IO.Path]::GetFileName($SettingsFile) + +$rawaccel_exe = Join-Path $PSScriptRoot rawaccel.exe +$writer_exe = Join-Path $PSScriptRoot writer.exe + +if (Test-Path -PathType 'Container' -Path $settingsDirectory) { + Start-Process -WorkingDirectory $settingsDirectory -FilePath $writer_exe -ArgumentList $settingsFileName +} elseif (New-Item -ItemType 'directory' -Path $settingsDirectory -Force) { + Start-Process -WorkingDirectory $settingsDirectory -FilePath $rawaccel_exe +} \ No newline at end of file diff --git a/install-autorun.ps1 b/install-autorun.ps1 new file mode 100644 index 00000000..106d0c43 --- /dev/null +++ b/install-autorun.ps1 @@ -0,0 +1,27 @@ +# Run as administrator +if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) { + Start-Process -WorkingDirectory $PWD -FilePath PowerShell.exe -Verb Runas -ArgumentList $(('-File "{0}"' -f $MyInvocation.MyCommand.Path); $MyInvocation.UnboundArguments) + Exit +} + +$unlockScript = Join-Path $PSScriptRoot autorun.ps1 +$stateChangeTrigger = Get-CimClass ` + -Namespace ROOT\Microsoft\Windows\TaskScheduler ` + -ClassName MSFT_TaskSessionStateChangeTrigger + +Register-ScheduledTask ` + -Force ` + -TaskName 'Autorun on sign in' ` + -TaskPath '\Raw Accel\' ` + -Description 'Apply user specific Raw Accel settings at sign in for each user.' ` + -Principal (New-ScheduledTaskPrincipal -GroupId Users) ` + -Trigger (New-ScheduledTaskTrigger -AtLogOn), ` + ( + New-CimInstance $stateChangeTrigger ` + -Property @{ + StateChange = 8 # TASK_SESSION_STATE_CHANGE_TYPE.TASK_SESSION_UNLOCK (taskschd.h) + } ` + -ClientOnly + ) ` + -Action (New-ScheduledTaskAction -Execute 'PowerShell' -Argument ('-WindowStyle Hidden -File "{0}"' -f $unlockScript)) ` + -Settings (New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -ExecutionTimeLimit 0) diff --git a/uninstall-autorun.ps1 b/uninstall-autorun.ps1 new file mode 100644 index 00000000..6da44c77 --- /dev/null +++ b/uninstall-autorun.ps1 @@ -0,0 +1,10 @@ +# Run as administrator +if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) { + Start-Process -WorkingDirectory $PWD -FilePath PowerShell.exe -Verb Runas -ArgumentList $(('-File "{0}"' -f $MyInvocation.MyCommand.Path); $MyInvocation.UnboundArguments) + Exit +} + +Unregister-ScheduledTask ` + -TaskName 'Autorun on sign in' ` + -TaskPath '\Raw Accel\' ` + -Confirm:$false \ No newline at end of file From 482cde043020350ef7ca3799fc2ea1f15b102b21 Mon Sep 17 00:00:00 2001 From: 0xFurtiv <84947139+0xFurtiv@users.noreply.github.com> Date: Wed, 10 Jul 2024 12:54:39 -0700 Subject: [PATCH 2/8] Rename $unlockScript to $autorunScript --- install-autorun.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install-autorun.ps1 b/install-autorun.ps1 index 106d0c43..bc6a4fa5 100644 --- a/install-autorun.ps1 +++ b/install-autorun.ps1 @@ -4,7 +4,7 @@ if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdent Exit } -$unlockScript = Join-Path $PSScriptRoot autorun.ps1 +$autorunScript = Join-Path $PSScriptRoot autorun.ps1 $stateChangeTrigger = Get-CimClass ` -Namespace ROOT\Microsoft\Windows\TaskScheduler ` -ClassName MSFT_TaskSessionStateChangeTrigger @@ -23,5 +23,5 @@ Register-ScheduledTask ` } ` -ClientOnly ) ` - -Action (New-ScheduledTaskAction -Execute 'PowerShell' -Argument ('-WindowStyle Hidden -File "{0}"' -f $unlockScript)) ` + -Action (New-ScheduledTaskAction -Execute 'PowerShell' -Argument ('-WindowStyle Hidden -File "{0}"' -f $autorunScript)) ` -Settings (New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -ExecutionTimeLimit 0) From 11eec996d12223989cbd9017de431911933241c4 Mon Sep 17 00:00:00 2001 From: 0xFurtiv <84947139+0xFurtiv@users.noreply.github.com> Date: Wed, 10 Jul 2024 13:07:11 -0700 Subject: [PATCH 3/8] Update Guide to include autorun --- doc/Guide.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/Guide.md b/doc/Guide.md index bb4e3ae4..5c6e3e0a 100644 --- a/doc/Guide.md +++ b/doc/Guide.md @@ -9,8 +9,14 @@ Visit the [Releases page](https://github.com/a1xd/rawaccel/releases) and navigat * Visual C++ 2019 runtime, [download here](https://aka.ms/vs/16/release/vc_redist.x64.exe) * .NET Framework 4.7.2+ runtime, [download here](https://dotnet.microsoft.com/download/dotnet-framework/net48) +We recommend copying the release directory into `%PROGRAMFILES%\Raw Accel`. + - Run `installer.exe` in the release directory to install the Raw Accel driver. Restart your computer for the installation to take effect. +- Run `install-autorun.ps1` in the release directory to enable user specific settings on sign in for each user. The settings are stored in `%LOCALAPPDATA%\Raw Accel` + +- Run `uninstall-autorun.ps1` in the release directory to disable user specific settings. + - Run `uninstaller.exe` in the release directory to uninstall the driver. Restart for the uninstallation to take effect. - Run `rawaccel.exe` when the driver is installed in order to run the Raw Accel GUI. From b31befadd6deab063e76e8426a35cf203c9cb1fe Mon Sep 17 00:00:00 2001 From: 0xFurtiv <84947139+0xFurtiv@users.noreply.github.com> Date: Wed, 10 Jul 2024 13:16:02 -0700 Subject: [PATCH 4/8] Add shortcut installer --- install-shortcut.ps1 | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 install-shortcut.ps1 diff --git a/install-shortcut.ps1 b/install-shortcut.ps1 new file mode 100644 index 00000000..2d151257 --- /dev/null +++ b/install-shortcut.ps1 @@ -0,0 +1,13 @@ +# Run as administrator +if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) { + Start-Process -WorkingDirectory $PWD -FilePath PowerShell.exe -Verb Runas -ArgumentList $(('-File "{0}"' -f $MyInvocation.MyCommand.Path); $MyInvocation.UnboundArguments) + Exit +} + +$rawaccel_exe = Join-Path $PSScriptRoot rawaccel.exe + +$shell = New-Object -comObject WScript.Shell +$shortcut = $shell.CreateShortcut('C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Raw Accel.lnk') +$shortcut.TargetPath = $rawaccel_exe +$Shortcut.WorkingDirectory = '%LOCALAPPDATA%\Raw Accel' +$shortcut.Save() \ No newline at end of file From 8251ad831d02b45514504a7df7f3e0090bc2c37b Mon Sep 17 00:00:00 2001 From: 0xFurtiv <84947139+0xFurtiv@users.noreply.github.com> Date: Wed, 10 Jul 2024 13:21:11 -0700 Subject: [PATCH 5/8] Add shortcut installation instructions --- doc/Guide.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/doc/Guide.md b/doc/Guide.md index 5c6e3e0a..b2164dd0 100644 --- a/doc/Guide.md +++ b/doc/Guide.md @@ -15,12 +15,16 @@ We recommend copying the release directory into `%PROGRAMFILES%\Raw Accel`. - Run `install-autorun.ps1` in the release directory to enable user specific settings on sign in for each user. The settings are stored in `%LOCALAPPDATA%\Raw Accel` +- Run `install-shortcut.ps1` in the release directory to add a user specific shortcut to the Raw Accel GUI. The settings are stored in `%LOCALAPPDATA%\Raw Accel`. Sign out and back in for the installation to take effect. + +- Run `rawaccel.exe` when the driver is installed in order to run the Raw Accel GUI. + +## Uninstallation + - Run `uninstall-autorun.ps1` in the release directory to disable user specific settings. - Run `uninstaller.exe` in the release directory to uninstall the driver. Restart for the uninstallation to take effect. -- Run `rawaccel.exe` when the driver is installed in order to run the Raw Accel GUI. - ## Philosophy The Raw Accel driver and GUI's workings and exposed parameters are based on our understanding of mouse acceleration. Our understanding includes the concepts of "[gain](#gain-switch)", "[whole vs by component](#horizontal-and-vertical)", and "[anisotropy](#anisotropy)." For clarity, we will outline this understanding here. Those uninterested can skip to [Features](#features) below. From 21bbd0cfa441a5f743c4a8f7cb5f40a90664000d Mon Sep 17 00:00:00 2001 From: 0xFurtiv <84947139+0xFurtiv@users.noreply.github.com> Date: Wed, 10 Jul 2024 13:21:48 -0700 Subject: [PATCH 6/8] Update Guide.md --- doc/Guide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/Guide.md b/doc/Guide.md index b2164dd0..bbf0daff 100644 --- a/doc/Guide.md +++ b/doc/Guide.md @@ -13,7 +13,7 @@ We recommend copying the release directory into `%PROGRAMFILES%\Raw Accel`. - Run `installer.exe` in the release directory to install the Raw Accel driver. Restart your computer for the installation to take effect. -- Run `install-autorun.ps1` in the release directory to enable user specific settings on sign in for each user. The settings are stored in `%LOCALAPPDATA%\Raw Accel` +- Run `install-autorun.ps1` in the release directory to enable user specific settings on sign in for each user. The settings are stored in `%LOCALAPPDATA%\Raw Accel`. - Run `install-shortcut.ps1` in the release directory to add a user specific shortcut to the Raw Accel GUI. The settings are stored in `%LOCALAPPDATA%\Raw Accel`. Sign out and back in for the installation to take effect. From 2ac90def564166ec3083494ad4ccdfb4872a7dde Mon Sep 17 00:00:00 2001 From: 0xFurtiv <84947139+0xFurtiv@users.noreply.github.com> Date: Wed, 10 Jul 2024 15:05:27 -0700 Subject: [PATCH 7/8] Use ProgramData environment variable for start menu path --- install-shortcut.ps1 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/install-shortcut.ps1 b/install-shortcut.ps1 index 2d151257..ba6dd587 100644 --- a/install-shortcut.ps1 +++ b/install-shortcut.ps1 @@ -7,7 +7,8 @@ if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdent $rawaccel_exe = Join-Path $PSScriptRoot rawaccel.exe $shell = New-Object -comObject WScript.Shell -$shortcut = $shell.CreateShortcut('C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Raw Accel.lnk') +$shortcut = $shell.CreateShortcut("$Env:PROGRAMDATA\Microsoft\Windows\Start Menu\Programs\Raw Accel.lnk") $shortcut.TargetPath = $rawaccel_exe $Shortcut.WorkingDirectory = '%LOCALAPPDATA%\Raw Accel' -$shortcut.Save() \ No newline at end of file +$Shortcut.Description = 'Edit mouse acceleration curves' +$shortcut.Save() From dd33d44d62b0708e93c6596fa35cd002e90b7464 Mon Sep 17 00:00:00 2001 From: 0xFurtiv <84947139+0xFurtiv@users.noreply.github.com> Date: Wed, 10 Jul 2024 15:17:48 -0700 Subject: [PATCH 8/8] =?UTF-8?q?Change=20copying=20=E2=86=92=20extracting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/Guide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/Guide.md b/doc/Guide.md index bbf0daff..c977dfa6 100644 --- a/doc/Guide.md +++ b/doc/Guide.md @@ -9,7 +9,7 @@ Visit the [Releases page](https://github.com/a1xd/rawaccel/releases) and navigat * Visual C++ 2019 runtime, [download here](https://aka.ms/vs/16/release/vc_redist.x64.exe) * .NET Framework 4.7.2+ runtime, [download here](https://dotnet.microsoft.com/download/dotnet-framework/net48) -We recommend copying the release directory into `%PROGRAMFILES%\Raw Accel`. +We recommend extracting the release directory into `%PROGRAMFILES%\Raw Accel`. - Run `installer.exe` in the release directory to install the Raw Accel driver. Restart your computer for the installation to take effect.