Skip to content

Commit 662878b

Browse files
committed
Enhancements for initial release
- Fix build script on PowerShell 5.x - Add progress bar - Update readme file
1 parent 3bbd1ce commit 662878b

File tree

3 files changed

+101
-18
lines changed

3 files changed

+101
-18
lines changed

README.md

+66-14
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,80 @@ AutoHotKey automation for RAMMap.
44

55
## Installation
66

7-
TODO: Describe the installation process
7+
The `build.cmd|ps1` scripts provide two capabilities:
8+
9+
- **Download** the latest RAMMap executable (Switch: `-DownloadRamMap`, Default: `false`)
10+
- **Download** the latest AutoHotKey and **compile** the AutoHotKey script into a self contained executable (Switch: `-CompileExecutable`, Default: `true`)
11+
12+
> **Note:** The `build.cmd` is only a wrapper for `build.ps1` script!
13+
14+
The `clean.cmd` only remove the build artifacts from `build.cmd|ps1`!
15+
16+
### Example
17+
18+
Download RAMMap, download AutoHotKey and compile AutoHotKey script to EXE:
19+
20+
```bat
21+
build.cmd|ps1 -DownloadRamMap -CompileExecutable
22+
```
23+
24+
The output is under `_build` directory:
25+
26+
```txt
27+
_build
28+
| rammap-cleanup.exe
29+
| RAMMap.exe
30+
|
31+
\---ahk
32+
| AutoHotkey.chm
33+
| AutoHotkeyA32.exe
34+
| AutoHotkeyU32.exe
35+
| AutoHotkeyU64.exe
36+
| Installer.ahk
37+
| license.txt
38+
| Template.ahk
39+
| WindowSpy.ahk
40+
|
41+
\---Compiler
42+
Ahk2Exe.exe
43+
ANSI 32-bit.bin
44+
readme.txt
45+
Unicode 32-bit.bin
46+
Unicode 64-bit.bin
47+
```
848

949
## Usage
1050

11-
TODO: Write usage instructions
51+
> **NOTE:** Needs elevation and runs with administrative privileges.
1252
13-
## Contributing
53+
### Run script
1454

15-
1. Fork it!
16-
2. Create your feature branch: `git checkout -b my-new-feature`
17-
3. Commit your changes: `git commit -am 'Add some feature'`
18-
4. Push to the branch: `git push origin my-new-feature`
19-
5. Submit a pull request :D
55+
```bat
56+
AutoHotkey.exe src/rammap-cleanup.ahk
57+
```
58+
59+
### Run compiled executable
60+
61+
```bat
62+
_build/rammap-cleanup.exe
63+
```
2064

21-
## History
65+
### Commandline arguments
2266

23-
TODO: Write history
67+
The first argument can be the path to an existing `RAMMap.exe` executable on the machine, e.g.:
2468

25-
## Credits
69+
```bat
70+
AutoHotkey.exe src/rammap-cleanup.ahk C:/Program Files/Sysint/RAMMap.exe
71+
_build_/rammap-cleanup.exe C:/Program Files/Sysint/RAMMap.exe
72+
```
2673

27-
TODO: Write credits
74+
> **NOTE:** If no path to `RAMMap.exe` is specified the AutoHotKey script search under the current
75+
> directory and then search for `RAMMap.exe` in all paths defined in the `PATH` environment variable.
2876
29-
## License
77+
## Contributing
3078

31-
TODO: Write license
79+
1. Fork it!
80+
2. Create your feature branch: `git checkout -b my-new-feature`
81+
3. Commit your changes: `git commit -am 'Add some feature'`
82+
4. Push to the branch: `git push origin my-new-feature`
83+
5. Submit a pull request :D

build.ps1

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Set-ScriptArgs $MyInvocation.BoundParameters $MyInvocation.UnboundArguments
2727
function Get-FileFromUrl([string] $name, [string] $url) {
2828
Log info "Download '$name' from '$url'..."
2929

30-
$fileName = [System.IO.FileInfo]::new($url).Name
30+
$fileName = [System.IO.Path]::GetFileName($url)
3131
$downloadedFile = Join-Path $env:TEMP $fileName
3232

3333
Invoke-WebRequest -Uri $url -Method Get -OutFile $downloadedFile -UseBasicParsing
@@ -50,7 +50,7 @@ try {
5050

5151
if ($DownloadRamMap) {
5252
$ramMapDownloadUrl = 'https://live.sysinternals.com/RAMMap.exe'
53-
$ramMapFileName = [System.IO.FileInfo]::new($ramMapDownloadUrl).Name
53+
$ramMapFileName = [System.IO.Path]::GetFileName($ramMapDownloadUrl)
5454
New-DirectoryIfNotExists $outputDir
5555

5656
$ramMapDestination = Join-Path $outputDir $ramMapFileName
@@ -63,7 +63,7 @@ try {
6363
}
6464
}
6565

66-
if ($CompileExecutable) {
66+
if (-not $CompileExecutable.IsPresent -or $CompileExecutable) {
6767
$ahkDownloadUrl = 'https://www.autohotkey.com/download/ahk.zip'
6868
$ahkPath = Join-Path $outputDir 'ahk'
6969
New-DirectoryIfNotExists $ahkPath

src/rammap-cleanup.ahk

+32-1
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,29 @@
22

33
SetTitleMatchMode RegEx
44

5+
ExpandToFullPath(file) {
6+
shell := ComObjCreate("WScript.Shell")
7+
exec := shell.Exec(ComSpec " /C where.exe " file)
8+
return % exec.StdOut.ReadAll()
9+
}
10+
511
GetRamMapExe() {
612
If (A_Args.Length() > 0) {
713
ramMapFilePath := A_Args[1]
814
}
9-
Else {
15+
16+
if (!FileExist(ramMapFilePath)) {
1017
ramMapFilePath := A_ScriptDir . "/RAMMap.exe"
1118
}
1219

20+
if (!FileExist(ramMapFilePath)) {
21+
ramMapFilePath := ExpandToFullPath("RAMMap.exe")
22+
}
23+
24+
ramMapFilePath := StrReplace(ramMapFilePath, "`r")
25+
ramMapFilePath := StrReplace(ramMapFilePath, "`n")
26+
ramMapFilePath := Trim(ramMapFilePath)
27+
1328
If (!FileExist(ramMapFilePath)) {
1429
MsgBox, RAMMap.exe could not be found.
1530
ExitApp, -1
@@ -145,23 +160,39 @@ If (!WinExist(GetRamMapTitle())) {
145160
ExitApp, -1
146161
}
147162

163+
Progress, p15, Preparing, Cleanup, RAMMap Cleanup
164+
148165
WaitUntilFinished()
149166

167+
Progress, 30, Empty Working Sets
168+
150169
EmptyWorkingSets()
151170
WaitUntilFinished()
152171

172+
Progress, 45, Empty System Working Set
173+
153174
EmptySystemWorkingSet()
154175
WaitUntilFinished()
155176

177+
Progress, 60, Empty Modified Page List
178+
156179
EmptyModifiedPageList()
157180
WaitUntilFinished()
158181

182+
Progress, 75, Empty Standby List
183+
159184
EmptyStandbyList()
160185
WaitUntilFinished()
161186

187+
Progress, 90, Empty Priority0 Standby List
188+
162189
EmptyPriority0StandbyList()
163190
WaitUntilFinished()
164191

192+
Progress, 100, Finishing
193+
Sleep, 2000
194+
Progress, Off
195+
165196
CloseRamMap()
166197
WinWaitClose, GetRamMapTitle(),, 5
167198

0 commit comments

Comments
 (0)