-
Notifications
You must be signed in to change notification settings - Fork 6
/
DialogJump.ahk
60 lines (50 loc) · 1.84 KB
/
DialogJump.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
; DialogJump
; Description: When in the editor of the file dialog, press Ctrl+G to jump to the last activated folder of listers. If Ctrl+G does not work, type "//cur " to trigger it. (AHK v2)
; Author: Chaoses Ib
; Version: 220519.2
; Git: https://github.com/Chaoses-Ib/IbDOpusScripts
dopusrt := GetDOpusRT()
DOpus_SendPath(){
global dopusrt
if (dopusrt == "")
dopusrt := GetDOpusRT()
if (A_IsAdmin) {
; running DOpusRT as elevated can't get the result
FileDelete(A_Temp "\DOpus_pathlist.txt")
RunAsUnelevated(dopusrt, "/info " A_Temp "\DOpus_pathlist.txt,paths")
while !FileExist(A_Temp "\DOpus_pathlist.txt") {
Sleep(20)
}
} else {
RunWait dopusrt " /info " A_Temp "\DOpus_pathlist.txt,paths"
}
paths := FileRead(A_Temp "\DOpus_pathlist.txt")
RegExMatch(paths, '<path active_lister="1" [^>]* tab_state="1">([^<]*)' , &Match)
if(!Match)
return
clipboard := ClipboardAll()
A_Clipboard := Match[1]
Send "+{Insert}`n" ;or ^v
Sleep 200
A_Clipboard := clipboard
clipboard := ""
;Send "{Text}" Match[1] "`n"
;incompatible with some input methods (Sogou Pinyin)
}
#HotIf WinActive("ahk_class #32770") ;File dialog
^g::DOpus_SendPath()
#HotIf
#Hotstring EndChars `n `t
:OX://cur::DOpus_SendPath()
GetDOpusRT(){
try
return StrReplace(WinGetProcessPath("ahk_exe dopus.exe"), "dopus.exe", "dopusrt.exe")
catch TargetError
; WinGetProcessPath requires the target to have a window
return ""
;return A_ProgramFiles . "\GPSoftware\Directory Opus\dopusrt.exe"
}
; From Bluesmaster, https://www.autohotkey.com/board/topic/72812-run-as-standard-limited-user/?p=670991
RunAsUnelevated(prms*){
ComObject("Shell.Application").Windows.FindWindowSW(0, 0, 8, 0, 1 ).Document.Application.ShellExecute(prms*)
}