Skip to content

Commit

Permalink
Embed .ico resources (some icons used previously from shell32.dll wer…
Browse files Browse the repository at this point in the history
…e not present on older OSes)
  • Loading branch information
benallred committed Dec 28, 2015
1 parent ef1e05b commit bfa8a07
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 14 deletions.
12 changes: 8 additions & 4 deletions BuildRelease.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@ function BuildRelease([string]$releaseVersion, [int]$architecture)
New-Item -type directory -path $tmpDir
}

# ahk2exe directives used in SnapX.ahk are not currently supported by ahk2exe master branch.
# Download latest preview from https://autohotkey.com/boards/viewtopic.php?f=24&t=521,
# rename it with ".Preview<version>", and put it in the AutoHotkey Compiler directory.
# & $compilerDir\Ahk2Exe.exe /in SnapX.ahk /out $tmpDir\SnapX.exe /icon Resources\SnapX.ico /bin "$compilerDir\Unicode $architecture-bit.bin"
& $compilerDir\Ahk2Exe.Preview2a.exe /in SnapX.ahk /out $tmpDir\SnapX.exe /bin "$compilerDir\Unicode $architecture-bit.bin"
# # ahk2exe directives used in SnapX.ahk are not currently supported by ahk2exe master branch.
# # Download latest preview from https://autohotkey.com/boards/viewtopic.php?f=24&t=521,
# # rename it with ".Preview<version>", and put it in the AutoHotkey Compiler directory.
# & $compilerDir\Ahk2Exe.Preview2a.exe /in SnapX.ahk /out $tmpDir\SnapX.exe /bin "$compilerDir\Unicode $architecture-bit.bin"
# In addition to the comment above, I have also added .ico resource support to my own fork of Ahk2Exe.
# Until a new preview is released that supports .ico resources (either via my pull request or another
# way (eg, an AHK expert doing it better)), clone and reference my fork.
& "..\Ahk2Exe\benallred\Ahk2Exe.ahk" /in SnapX.ahk /out $tmpDir\SnapX.exe /bin "$compilerDir\Unicode $architecture-bit.bin"

Start-Sleep -s 5 # just waiting for the .exe to appear (like the .zip file below) is a little premature because there is also a temporary file there with it for a little longer

Expand Down
55 changes: 45 additions & 10 deletions Modules/Tray.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@ class Tray
{
initIcon()
{
Menu, Tray, Icon, shell32.dll, 160 ; other options: 16, 253, 255, 306
if (A_IsCompiled)
{
Menu, Tray, Icon, % A_ScriptName, 1
}
else
{
Menu, Tray, Icon, Resources\SnapX.ico
}
Menu, Tray, NoStandard
}

Expand All @@ -16,33 +23,47 @@ class Tray

aboutMethod := ObjBindMethod(this, "tray_About")
Menu, Tray, Add, % this.settings.programTitle, % aboutMethod
Menu, Tray, Icon, % this.settings.programTitle, shell32.dll, 160

Menu, Tray, Add, &About, % aboutMethod
Menu, Tray, Icon, &About, shell32.dll, 222 ; other options: 155, 176, 211, 222, 225, 278

updateMethod := ObjBindMethod(this, "tray_Update")
Menu, Tray, Add, Chec&k for update, % updateMethod
Menu, Tray, Icon, Chec&k for update, shell32.dll, 47 ; other options: 47, 123

Menu, Tray, Add

settingsMethod := ObjBindMethod(this, "tray_Settings")
Menu, Tray, Add, &Settings, % settingsMethod
Menu, Tray, Icon, &Settings, shell32.dll, 316

reloadMethod := ObjBindMethod(this, "tray_Reload")
Menu, Tray, Add, &Reload, % reloadMethod
Menu, Tray, Icon, &Reload, shell32.dll, 239

suspendMethod := ObjBindMethod(this, "tray_Suspend")
Menu, Tray, Add, S&uspend, % suspendMethod
Menu, Tray, Icon, S&uspend, shell32.dll, 145 ; other options: 238, 220

exitMethod := ObjBindMethod(this, "tray_Exit")
Menu, Tray, Add, E&xit, % exitMethod
Menu, Tray, Icon, E&xit, shell32.dll, 132

if (A_IsCompiled)
{
Menu, Tray, Icon, % this.settings.programTitle, % A_ScriptName, 1
Menu, Tray, Icon, &About, % A_ScriptName, 6
Menu, Tray, Icon, Chec&k for update, % A_ScriptName, 7
Menu, Tray, Icon, &Settings, % A_ScriptName, 8
Menu, Tray, Icon, &Reload, % A_ScriptName, 9
Menu, Tray, Icon, S&uspend, % A_ScriptName, 10
Menu, Tray, Icon, E&xit, % A_ScriptName, 12
}
else
{
Menu, Tray, Icon, % this.settings.programTitle, Resources\SnapX.ico
Menu, Tray, Icon, &About, Resources\About.ico
Menu, Tray, Icon, Chec&k for update, Resources\Update.ico
Menu, Tray, Icon, &Settings, Resources\Settings.ico
Menu, Tray, Icon, &Reload, Resources\Reload.ico
Menu, Tray, Icon, S&uspend, Resources\Suspend.ico
Menu, Tray, Icon, E&xit, Resources\Exit.ico
}

Menu, Tray, Default, % this.settings.programTitle
Menu, Tray, Tip, % this.settings.programTitle
}
Expand Down Expand Up @@ -81,12 +102,26 @@ class Tray
if (A_IsSuspended)
{
Menu, Tray, Rename, Res&ume, S&uspend
Menu, Tray, Icon, S&uspend, shell32.dll, 145
if (A_IsCompiled)
{
Menu, Tray, Icon, S&uspend, % A_ScriptName, 10
}
else
{
Menu, Tray, Icon, S&uspend, Resources\Suspend.ico
}
}
else
{
Menu, Tray, Rename, S&uspend, Res&ume
Menu, Tray, Icon, Res&ume, shell32.dll, 302
if (A_IsCompiled)
{
Menu, Tray, Icon, Res&ume, % A_ScriptName, 11
}
else
{
Menu, Tray, Icon, Res&ume, Resources\Resume.ico
}
}

Suspend, Toggle
Expand Down
Binary file added Resources/About.ico
Binary file not shown.
Binary file added Resources/Exit.ico
Binary file not shown.
Binary file added Resources/Reload.ico
Binary file not shown.
Binary file added Resources/Resume.ico
Binary file not shown.
Binary file added Resources/Settings.ico
Binary file not shown.
Binary file added Resources/Suspend.ico
Binary file not shown.
Binary file added Resources/Update.ico
Binary file not shown.
8 changes: 8 additions & 0 deletions SnapX.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
; @ Ahk2Exe-SetDescription ; this is set in Settings.ahk
; @ Ahk2Exe-SetVersion ; this is set in Build.ahk

;@Ahk2Exe-AddResource Resources\About.ico
;@Ahk2Exe-AddResource Resources\Update.ico
;@Ahk2Exe-AddResource Resources\Settings.ico
;@Ahk2Exe-AddResource Resources\Reload.ico
;@Ahk2Exe-AddResource Resources\Suspend.ico
;@Ahk2Exe-AddResource Resources\Resume.ico
;@Ahk2Exe-AddResource Resources\Exit.ico

; Third-party libraries

#Include Include\WinGetPosEx.ahk
Expand Down

0 comments on commit bfa8a07

Please sign in to comment.