此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
$ `% b! u" [8 c% D8 X( M3 M2 I& b 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
2 p* S% u7 }4 Q7 S5 [+ I 方式一:5 \( M$ G5 E2 @: A+ @/ m$ u
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
7 h' B7 z% h" A9 ` 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和/ G% y# w. V' ]3 g
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。- b+ L9 D( Z! c. L. c0 U( B
方式二:
# O$ V1 k% q4 u9 Y 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
" l1 l8 J/ N, j4 W# O SetTitleMatchMode RegEx* @* y1 c; v/ ~2 d9 Z/ r- q i+ L
return
8 i- F$ b2 I& I: c ; Stuff to do when Windows Explorer is open, ^7 ?9 N; |, U0 c; a! ]
;: L2 u+ _5 n% T' e C* A
#IfWinActive ahk_class ExploreWClass|CabinetWClass
+ G4 K- J H; O ; open ‘cmd’ in the current directory2 O; D7 ]- ]( |. I k" ^2 L. z
;! O5 e* R# B% ?" n5 l
#c::
8 ^, h1 Q0 x4 e9 V OpenCmdInCurrent()
: h* R0 T& @5 ~ return
& P* V n. i0 {2 v) I #IfWinActive G7 ^7 o+ Q1 I' e4 j
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.# Z6 C2 r' M; p7 W; v$ `
; Note: expecting to be run when the active window is Explorer." m. @$ d) F; B
;6 @. P9 T( ~3 H8 ]5 g; B4 \1 r# U, G
OpenCmdInCurrent(). o- d- D Z" j) ]% _" A2 c$ T
{- w: Z$ m0 U' W
; This is required to get the full path of the file from the address bar+ k) `* @9 }5 }5 f5 _* i
WinGetText, full_path, A- {& W+ d2 z; L6 a" l: \. q; N
; Split on newline (`n)
* j7 M6 X& @% @! F7 S StringSplit, word_array, full_path, `n# F: u! H0 o; O" h3 B
; Take the first element from the array: a& z; O0 N4 m( W! x
full_path = %word_array1%, U* ]( C2 l0 J- }7 d
; strip to bare address. V I4 A0 a5 N& |+ T
full_path := RegExReplace(full_path, “地址: “, “”)
/ m) I) l o0 e h- d" j( ~ ; Just in case – remove all carriage returns (`r)8 G: p# O! l% | G' V) n$ ]0 h) `
StringReplace, full_path, full_path, `r, , all
7 d) z8 t4 Y- g5 H IfInString full_path, \* i4 u+ ^7 c5 f" r! b7 T
{
. q; p/ ]2 j: B0 u Run, cmd /K cd /D “%full_path%”, J$ P& g6 X) k4 D7 B9 ~) _% c
}
( N; w7 d/ r, H$ ?' u else
2 _! x! I' F3 i6 S7 p8 C0 @% h/ s) x {4 w" ]* r p* ]5 Z
Run, cmd /K cd /D “C:\ ”! w8 W7 V, @: j% x0 C$ z
}4 r( ?( r5 L2 m' x+ z, a9 C: i
}* f8 Q0 N% g6 @0 @6 j
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。- L% X& T3 Z0 n0 l
这段小代码肯能有两个你需要修改的地方0 I. ^( b! J7 [6 Y! a' h$ Z& q; i
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
) B7 l* d. M4 N) s3 s, t 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “' B5 p; K5 a+ o% O. E) E7 M o4 E$ }
|