-
Notifications
You must be signed in to change notification settings - Fork 1
/
eclipse-launcher.ahk
152 lines (124 loc) · 3.57 KB
/
eclipse-launcher.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/*******************************************************************************
* Copyright (C) 2022, 2023, Michael Keppler <michael.keppler@gmx.de>
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************
*/
; Eclipse Launcher - configuration section
; the directory to scan for nested installations
RootDir := "c:\dev"
; Folders to be shown on the top level of the resulting menu. Others will be shown in a sub menu only.
; type: regular expression
; default: all items displayed on top level
; example: to display only egit and platform on the top level, use "egit|platform"
TopLevelPattern := ".*"
; folder names to ignore
; type: regular expression string
; default: ignore folders containing "old" or "backup" or starting with an underscore
IgnorePattern := "^_|\bold|backup"
; Nothing to change below this line
; Recommended for performance and compatibility with future AutoHotkey releases.
#NoEnv
; Enable warnings to assist with detecting common errors.
#Warn
; Ensure a consistent starting directory.
SetWorkingDir %A_ScriptDir%
; Remain in memory
#Persistent
; Avoid accidentally running this multiple times.
#SingleInstance Force
; make DPI aware, https://www.autohotkey.com/docs/v1/misc/DPIScaling.htm
DllCall("SetThreadDpiAwarenessContext", "ptr", -4, "ptr")
; Disable tray icon
Menu, Tray, NoIcon
; scan for directories with eclipse.exe
FileList := ""
Loop, Files, %RootDir%\*, D
{
If IsIgnored(A_LoopFileName)
{
Continue
}
; check for nested \eclipse\eclipse.exe
IfExist, %RootDir%\%A_LoopFileName%\eclipse\eclipse.exe
{
FileList .= A_LoopFileName "`n"
}
}
; remove last newline and sort items
FileList := Trim(FileList, "`r`n")
Sort, FileList, CL
IconPath := ""
ShowSubMenu := false
Loop, parse, FileList, `n
{
FolderName := A_LoopField
If (IconPath == "")
{
; take the icon from the first installation and don't load each one separately
IconPath = %RootDir%\%FolderName%\eclipse\eclipse.exe
}
If IsTopLevel(FolderName)
{
; add as top level menu item
Menu, MyMenu, Add, %FolderName%, MenuStartEclipse
Menu, MyMenu, Icon, %FolderName%, %IconPath%, 1
}
else {
; add to submenu instead
Menu, MenuOther, Add, %FolderName%, MenuStartEclipse
Menu, MenuOther, Icon, %FolderName%, %IconPath%, 1
ShowSubMenu = true
}
}
; add the sub menu, if there were any items for it
If ShowSubMenu
{
; separator after all top level menu items
Menu, MyMenu, Add
; attach the sub menu to the main menu
Menu, MyMenu, Add, Other, :MenuOther
}
; menu item reload, needed to recognize new installations
Menu, MyMenu, Add
Menu, MyMenu, Add, Reload, MenuReload
Menu, MyMenu, Icon, Reload, shell32.dll, 239
Menu, MyMenu, Add, Edit, MenuEdit
Menu, MyMenu, Icon, Edit, shell32.dll, 270
; exit script, wait for hotkey
return
IsTopLevel(FolderName)
{
global TopLevelPattern
If (RegExMatch(FolderName, TopLevelPattern) > 0)
{
return true
}
return false
}
IsIgnored(FolderName)
{
global IgnorePattern
If (RegExMatch(FolderName, IgnorePattern) > 0)
{
return true
}
return false
}
MenuStartEclipse:
; use menu item to run a process, and set the working directory
Run, %RootDir%\%A_ThisMenuItem%\eclipse\eclipse.exe, %A_ThisMenuItem%\eclipse
return
MenuReload:
Reload
return
MenuEdit:
Run, notepad %A_ScriptFullPath%
return
; enable hotkey
^#e::Menu, MyMenu, Show ; Ctrl-Win-E