-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTerminaldauem_terminal.ahk
92 lines (82 loc) · 2.82 KB
/
Terminaldauem_terminal.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
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
; #NoTrayIcon
#SingleInstance Force
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
EnvGet, CMDER_INITBAT, CMDER_INITBAT
if !A_IsAdmin {
Run *Runas %A_ScriptFullPath%
ExitApp
}
$~^!t::
MouseGetPos, , , WndH
WinGet Process, ProcessName, ahk_id %WndH%
If ( Process = "explorer.exe" ) {
WinGetClass Class, ahk_id %WndH%
If ( Class ~= "Progman|WorkerW" )
Location := A_Desktop
Else If ( Class ~= "(Cabinet|Explore)WClass" )
{
For Window In ComObjCreate("Shell.Application").Windows
If ( Window.HWnd == WndH )
{
URL := Window.LocationURL
Break
}
StringTrimLeft, Location, URL, 8 ; remove "file:///"
StringReplace Location, Location, /, \, All
Location:=urlToText(Location)
}
if (Location == "")
{
ComObjCreate("Shell.Application").Windows.FindWindowSW(0, 0, 8, 0, 1).Document.Application.ShellExecute(Chr(34) ComSpec Chr(34),"/k ""title Cmder & cd /d C:\Users\" . A_UserName . " & %CMDER_INITBAT%""")
}
else
{
ComObjCreate("Shell.Application").Windows.FindWindowSW(0, 0, 8, 0, 1).Document.Application.ShellExecute(Chr(34) ComSpec Chr(34),"/k ""title Cmder & cd /d " . Location . " & %CMDER_INITBAT%""")
}
}
return
$~^!+t::
MouseGetPos, , , WndH
WinGet Process, ProcessName, ahk_id %WndH%
If ( Process = "explorer.exe" ) {
WinGetClass Class, ahk_id %WndH%
If ( Class ~= "Progman|WorkerW" )
Location := A_Desktop
Else If ( Class ~= "(Cabinet|Explore)WClass" )
{
For Window In ComObjCreate("Shell.Application").Windows
If ( Window.HWnd == WndH )
{
URL := Window.LocationURL
Break
}
StringTrimLeft, Location, URL, 8 ; remove "file:///"
StringReplace Location, Location, /, \, All
Location:=urlToText(Location)
}
if (Location == "")
{
ComObjCreate("Shell.Application").Windows.FindWindowSW(0, 0, 8, 0, 1).Document.Application.ShellExecute(Chr(34) ComSpec Chr(34),"/k ""title Cmder & cd /d " . A_WINDIR . "\System32 & %CMDER_INITBAT%""" ,,"runas")
}
else
{
ComObjCreate("Shell.Application").Windows.FindWindowSW(0, 0, 8, 0, 1).Document.Application.ShellExecute(Chr(34) ComSpec Chr(34),"/k ""title Cmder & cd /d " . Location . " & %CMDER_INITBAT%""" ,,"runas")
}
}
return
^!ScrollLock::SendMessage, 0x112, 0xF140, 0,, Program Manager
^BS::
send, ^+{left}
sleep 1
send {Backspace}
return
urlToText(url) {
; https://www.autohotkey.com/boards/viewtopic.php?style=17&p=292740#p292740
VarSetCapacity(text, 600)
DllCall("shlwapi\PathCreateFromUrl" (A_IsUnicode?"W":"A")
, "Str", "file:" url, "Str", text, "UInt*", 300, "UInt", 0)
return text
}