-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathFolderMenuList v1.1.1.ahk
More file actions
102 lines (88 loc) · 2.77 KB
/
FolderMenuList v1.1.1.ahk
File metadata and controls
102 lines (88 loc) · 2.77 KB
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
#SingleInstance Force
#HotIf WinActive("ahk_class #32770")
^g::
{
global WinID := WinExist("A")
ContextMenu := Menu()
;---------------资源管理器-------------------------
For openedwindows in ComObject("shell.Application").windows
{
This := openedwindows.Document.Folder.Self.Path
ContextMenu.Add(This, MenuHandler)
ContextMenu.SetIcon(This, "shell32.dll", 5)
}
openedwindows := "" ;清空变量
;---------------Total Commander-------------------
if WinExist("ahk_class TTOTAL_CMD")
{
TCPath := WinGetProcessPath("ahk_class TTOTAL_CMD")
cm_CopySrcPathToClip := 2029 ;Total Commander 内部代码
cm_CopyTrgPathToClip := 2030
ClipSaved := ClipboardAll()
A_Clipboard := ""
SendMessage(1075, cm_CopySrcPathToClip, 0, , "ahk_class TTOTAL_CMD")
ContextMenu.Add
ContextMenu.Add(A_Clipboard, MenuHandler)
ContextMenu.SetIcon(A_Clipboard, TCPath, 1)
SendMessage(1075, cm_CopyTrgPathToClip, 0, , "ahk_class TTOTAL_CMD")
ContextMenu.Add(A_Clipboard, MenuHandler)
ContextMenu.SetIcon(A_Clipboard, TCPath, 1)
A_Clipboard := ClipSaved
ClipSaved := ""
}
;--------------常用文件夹-------
ContextMenu.Add
ContextMenu.Add("常用路径", MenuHandler)
ContextMenu.Disable("常用路径")
ContextMenu.Add("F:\图片\Pics\墙纸\bing", MenuHandler) ;如要添加自定义路径,可复制本行和下一行,只修改其中路径即可
ContextMenu.SetIcon("F:\图片\Pics\墙纸\bing", "shell32.dll", 44)
;ContextMenu.Add("%UserProfile%\", MenuHandler) ;用户文件夹
;ContextMenu.SetIcon("%UserProfile%\", "shell32.dll", 44)
;------------------------------
ContextMenu.Show
ContextMenu.Delete
}
#HotIf ;关闭上下文相关性
MenuHandler(ItemName, ItemPos, MyMenu)
{
WinActivate "ahk_id" WinID
try
{
if ControlGetEnabled("ToolbarWindow323", WinID) = 1 or ControlGetEnabled("ToolWindow324", WinID) = 1
{
Send "!d"
Sleep 100 ;等待获取焦点,如果设为 50 ,在 chrome 中另存为会出现焦点错误
addressbar := ControlGetFocus("A") ; 按下 alt+D 之后的焦点为地址栏
ControlSetText(ItemName, addressbar, "A")
ControlSend("{Enter}", addressbar, "A")
ControlFocus("Edit1", "A") ;焦点移回到 Edit1
}
}
catch TargetError
{
FolderPath := ItemName
OldText := ControlGetText("Edit1", "A") ;读取当前 Edit1 控件中的文件名
ControlFocus "Edit1", "A"
Loop 5
{
ControlSetText FolderPath, "Edit1", "ahk_id" WinID
Sleep(50)
CurControlText := ControlGetText("Edit1", "ahk_id" WinID)
if (CurControlText = FolderPath)
break
}
Sleep 50
ControlSend "{Enter}", "Edit1", "A"
Sleep 50
If !OldText ;插入原始文件名
return
Loop 5
{
ControlSetText OldText, "Edit1", "A"
Sleep 50
CurControlText := ControlGetText("Edit1", "A")
if (CurControlText = OldText)
break
}
}
}