-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathLButtonOnEditScriptMenuItem.ahk
58 lines (46 loc) · 1.52 KB
/
LButtonOnEditScriptMenuItem.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
; Title: https://www.autohotkey.com/boards/viewtopic.php?t=38875
; Link:
; Author:
; Date:
; for: AHK_L
/*
MyEditor := "Notepad++.exe"
SetBatchLines, -1
OnMessage( 0x111, Func("WM_COMMAND").Bind(MyEditor) )
Return
#If scriptPath := LButtonOnEditScriptMenuItem()
LButton:: Run %MyEditor% "%scriptPath%"
*/
LButtonOnEditScriptMenuItem() {
CoordMode, Mouse
MouseGetPos, X, Y, hWnd
WinGetClass, WinClass, ahk_id %hWnd%
if (WinClass != "#32768")
Return
WinGet, PID, PID, ahk_id %hWnd%
DetectHiddenWindows, On
if !WinExist("ahk_class AutoHotkey ahk_pid " . PID)
Return
SendMessage, MN_GETHMENU := 0x1E1,,,, ahk_id %hWnd%
hMenu := ErrorLevel
POINT := X | Y << 32
VarSetCapacity(RECT, 16, 0)
Loop % DllCall("GetMenuItemCount", Ptr, hMenu)
DllCall("GetMenuItemRect", Ptr, 0, Ptr, hMenu, UInt, pos := A_Index - 1, Ptr, &RECT)
until DllCall("PtInRect", Ptr, &RECT, Int64, POINT)
VarSetCapacity(itemText, 64, 0)
DllCall("GetMenuString", Ptr, hMenu, UInt, pos, Str, itemText, Int, 32, UInt, MF_BYPOSITION := 0x400)
if !(itemText = "&Edit This Script" || itemText = "&Edit Script" . A_Tab . "Ctrl+E")
Return
WinClose, ahk_id %hWnd%
WinGetTitle, title
Return scriptPath := RegExReplace(title, "(.*\.ahk) - AutoHotkey v.*", "$1")
}
WM_COMMAND(MyEditor, wp) {
static ID_FILE_EDITSCRIPT := 65401, ID_TRAY_EDITSCRIPT := 65304
if wp in %ID_FILE_EDITSCRIPT%,%ID_TRAY_EDITSCRIPT%
{
Run %MyEditor% "%A_ScriptFullPath%"
Return 0
}
}