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

(WinPCap) Update for AHK V2 to work #2540

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
31 changes: 14 additions & 17 deletions deprecated/packages/winpcap/tools/chocolateyInstall.ps1
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
$ErrorActionPreference = 'Stop'
$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
$url = "$toolsDir\WinPcap_4_1_3.exe"
$ahkExe = 'AutoHotKey'
$ahkFile = "$toolsDir\winpcapInstall.ahk"

$toolsPath = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
$file = "$toolsPath\WinPcap_4_1_3.exe"
$packageArgs = @{
packageName = $packageName
fileType = 'EXE'
file = $url
silentArgs = '/S'
softwareName = "Winpcap"
}

Write-Output "Running Autohotkey installer"
$ahkScript = "$toolsPath\winpcapInstall.ahk"

# program cannot install properly on top of itself
# so if already installed (running choco install winpap --force)
# we first remove it
$softwareNamePattern = 'WinPcap*'
[array] $key = Get-UninstallRegistryKey $softwareNamePattern
if ($key.Count -eq 1) {
$key | ForEach-Object {
AutoHotkey $ahkScript uninstall $_.UninstallString
}
}

AutoHotkey $ahkScript install $file
Start-Process $ahkExe $ahkFile
Install-ChocolateyInstallPackage @packageArgs
Remove-Item $url -Force -ErrorAction SilentlyContinue | Out-Null
22 changes: 0 additions & 22 deletions deprecated/packages/winpcap/tools/chocolateyUninstall.ps1

This file was deleted.

63 changes: 23 additions & 40 deletions deprecated/packages/winpcap/tools/winpcapInstall.ahk
Original file line number Diff line number Diff line change
@@ -1,45 +1,28 @@
#Requires AutoHotkey v2.0
; #Warn ; Enable warnings to assist with detecting common errors.
SetWorkingDir(A_ScriptDir) ; Ensures a consistent starting directory.
SetTitleMatchMode("RegEx")
SendMode "Input" ; Recommended for new scripts due to its superior speed and reliability.

if (A_Args.Length < 2) {
MsgBox("Too few arguments given: " . A_Args[1])
exit
}
WinWait("WinPcap",, 30)

hitEnter() {
BlockInput "On"
Sleep 250
WinActivate
Send "{Enter}"
BlockInput "Off"
return
}
BlockInput "On"
Sleep 250
WinActivate
Send "{Enter}"
BlockInput "Off"

run_cmd_enter(title_string, loops, check_string := "") {
WinWait(title_string, check_string, 30)
Loop loops {
hitEnter
}
return
}
BlockInput "On"
Sleep 250
WinActivate
Send "{Enter}"
BlockInput "Off"

operation := A_Args[1]
runfile := A_Args[2]
BlockInput "On"
Sleep 250
WinActivate
Send "{Enter}"
BlockInput "Off"

Run runfile
switch operation {
case "uninstall":
uninstallTitle := "WinPcap [\d\.]+ Uninstall"
run_cmd_enter(uninstallTitle, 1)
run_cmd_enter(uninstallTitle, 1, "has been uninstalled")
case "install":
installTitle := "WinPcap [\d\.]+ Setup"
run_cmd_enter(installTitle, 3)
run_cmd_enter(installTitle, 1, "has been installed")
default:
MsgBox("Unsupported operation: " . operation)
exit
}
ExitApp
WinWait("WinPcap", "has been installed", 30)
BlockInput "On"
Sleep 250
WinActivate
Send "{Enter}"
BlockInput "Off"