-
Notifications
You must be signed in to change notification settings - Fork 0
/
20141112_QuickOpen.ahk
128 lines (103 loc) · 3.33 KB
/
20141112_QuickOpen.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
;Created by P. Zheng
;Version: 2.0.0
;Date: Jul. 24 2013
#SingleInstance force
#NoTrayIcon
;Pre-define parameters as default
EditLoadParams := "D:\params.txt"
EditLoadUltraedit := "C:\Program Files\IDM Computer Solutions\UltraEdit\Uedit32.exe"
;Add menu for this GUI
Menu, HelpMenu, Add, &About, HelpAbout
Menu, MyMenuBar, Add, &Help, :HelpMenu
Gui, Menu, MyMenuBar
Gui, Add, Edit, vEditLoadParams x42 y30 w320 h20 , Please load params.txt...
Gui, Add, GroupBox, x22 y10 w390 h50 , Params.txt
Gui, Add, Button, x372 y30 w30 h20 gLoadParams, ...
Gui, Add, Edit, vEditLoadUltraedit x42 y90 w320 h20 , Please load UltraEdit editor...
Gui, Add, GroupBox, x22 y70 w390 h50 , Uedit32.exe
Gui, Add, Button, x372 y90 w30 h20 gLoadUltraedit, ...
Gui, Show, x433 y272 h135 w429, QuickOpen
Return
LoadParams:
Gui +OwnDialogs ; Force the user to dismiss the FileSelectFile dialog before returning to the main window.
FileSelectFile, SelectedParamsTxt, 3,%EditLoadParams%, Select File, Params (*.txt)
if SelectedParamsTxt = ; No file selected.
return
else
GuiControl,, EditLoadParams, %SelectedParamsTxt%
return
LoadUltraedit:
Gui +OwnDialogs ; Force the user to dismiss the FileSelectFile dialog before returning to the main window.
FileSelectFile, SelectedUltraedit, 3,%EditLoadUltraedit%, Select File, Uedit32 (*.exe)
if SelectedUltraedit = ; No file selected.
return
else
GuiControl,, EditLoadUltraedit, %SelectedUltraedit%
return
HelpAbout:
Gui, 2:+owner1 ; Make the main window (Gui #1) the owner of the "about box" (Gui #2).
Gui +Disabled ; Disable main window.
Gui, 2:Add, Button, x266 y7 w100 h30 , OK
Gui, 2:Add, Text, x26 y7 w170 h20 , QuickOpen v2.0.0 20130724
Gui, 2:Add, Text, x26 y27 w200 h20 , Press "Alt+O" to open relative path file.
Gui, 2:Add, Text, x26 y57 w170 h20 , Created By P. Zheng
Gui, 2:Add, Text, x26 y77 w170 h20 , www.pzheng.me
Gui, 2:Add, Text, x26 y97 w170 h20 , Powered by AutoHotKey
Gui, 2:Show, x406 y249 h118 w388,About
return
2ButtonOK: ; This section is used by the "help box" above.
2GuiClose:
2GuiEscape:
Gui, 1:-Disabled ; Re-enable the main window (must be done prior to the next step).
Gui Destroy ; Destroy the help box.
return
; "Alt + o" to quickly open relative path file.
!o::
Gui, Submit, NoHide
original = %clipboard%
Send {HOME}+{END}^c{END}
clipwait
StringReplace, clipboard, clipboard,`r`n,,All ;remove "Enter"
StringSplit, PathName, clipboard, ], ;split path name
Part1 = %PathName1%
FilePath = %PathName2% ;words after ]
StringSplit, FirstPart, Part1, [,
RelPath = %FirstPart2% ;words between [ and ]
ParamsPath := EditLoadParams
IfNotExist, %ParamsPath%
{
MsgBox, %ParamsPath% does not exist! Please load the correct params.txt.
return
}
UEPath := EditLoadUltraedit
Loop
{
FileReadLine, line, %ParamsPath%, %A_Index%
if ErrorLevel
break
IfInString, line, %RelPath% ;search the line with specific string in params.txt
break
}
IfInString, line, %RelPath%
StringSplit, DirName, line, ", ;split the line and get the first part of absolute path
else
{
MsgBox, Cannot find %RelPath% in params.txt
return
}
AbsPath = %DirName2%%PathName2% ;combine the absolute path
clipboard = %original%
IfExist, %UEPath%
{
run, %UEPath% %AbsPath%
return
}
else
{
MsgBox, %UEPath% does not exist! Please load the correct UltraEdit directory.
run, notepad %AbsPath%
return
}
return
GuiClose:
ExitApp