From 881d4f633e716a200fb0eb3812a386ca32af08d4 Mon Sep 17 00:00:00 2001 From: Arslan Charyyev Date: Sat, 17 Oct 2020 10:52:23 +0300 Subject: [PATCH] 1-click installer script Hello. First of all, I want to thank you for the AHI, it works well. However, I thought that the installation process could've been more streamlined. For this reason, I have made a script that automatically downloads, extracts, installs, and copies the latest versions of all the necessary packages. It cleans up after itself as well but leaves the AHI folder since it contains useful examples and tools (like `Monitor.ahk`). It also prompts to restart the computer at the end. It does not have any error checking routines, but it enforces the admin & version requirements to eliminate the most common issues. I'm posting it here in case someone might find it useful or convenient, under the CC0 license. --- install-ahi.ps1 | 68 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 install-ahi.ps1 diff --git a/install-ahi.ps1 b/install-ahi.ps1 new file mode 100644 index 0000000..b02c74c --- /dev/null +++ b/install-ahi.ps1 @@ -0,0 +1,68 @@ +#Requires -RunAsAdministrator +#Requires -Version 5.0 + +function GetLatestReleaseLink($repoURL) { + return (Invoke-WebRequest $repoURL | ConvertFrom-Json).assets[0].browser_download_url +} + +function Install-AHK { + # Download it + $installerURL = "https://www.autohotkey.com/download/ahk-install.exe" + Invoke-WebRequest($installerURL) -OutFile ahk-install.exe + + # Install it + .\ahk-install.exe /S +} + +function Install-Interception { + # Download it + $repoURL = "http://api.github.com/repos/oblitum/Interception/releases/latest" + Invoke-WebRequest(GetLatestReleaseLink($repoURL)) -OutFile Interception.zip + + # Unzip it + Expand-Archive Interception.zip -DestinationPath . -Force + + # Install it + & '.\Interception\command line installer\install-interception.exe' /install +} + +function Install-AHI { + # Download it + $repoURL = "http://api.github.com/repos/evilC/AutoHotInterception/releases/latest" + Invoke-WebRequest(GetLatestReleaseLink($repoURL)) -OutFile AutoHotInterception.zip + + # Unzip it + Expand-Archive AutoHotInterception.zip -DestinationPath AutoHotInterception -Force + + # Copy the Interception libs to AHI libs + robocopy Interception\library AutoHotInterception\Lib *.* /s /is /it + + # Unblock the DLLs + AutoHotInterception\Lib\Unblocker.ps1 + + # Copy libs to 'My Documents' + $myDocsLibDir = Join-Path -Path ([Environment]::GetFolderPath("MyDocuments")) -ChildPath "AutoHotkey\lib" + robocopy AutoHotInterception\Lib $myDocsLibDir *.* /s /is /it +} + + +function Clean-Up() { + Foreach ($item in "ahk-install.exe", "Interception.zip", "Interception", "AutoHotInterception.zip") { + Remove-Item -Recurse -Force $item + } +} + +function main { + # Change to script directory + Set-Location $PSScriptRoot + + Install-AHK + Install-Interception + Install-AHI + Clean-Up + + # Prompt for reboot + Restart-Computer -Confirm +} + +main