此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。$ R9 F; K, {# U5 I! p- j
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。! N5 T( {3 E- g3 |
方式一:
x. D# o/ C: Y' ^! v& d7 I 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
( @/ ]4 ]( i/ i 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和1 x6 s0 D, W/ Z% P+ w
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。& R% O X- {9 s7 o4 N; r6 _
方式二:7 Q* x& K; [7 g* n
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
. w) ~5 G/ Z3 q2 e! n, N; I6 _+ } SetTitleMatchMode RegEx
- R7 m6 \7 U9 Y0 `+ X( e f return
3 K& T6 X& h( W; S! N- t( h f ; Stuff to do when Windows Explorer is open$ j- i8 j0 Z, R, B; l# ?+ h! W$ }
;
4 o, o1 `$ c& l# n #IfWinActive ahk_class ExploreWClass|CabinetWClass
" V& S- f/ u6 Y- ^$ i9 v ; open ‘cmd’ in the current directory
* ~; c* ]% M/ ~6 z9 ^2 S; W8 m ;8 `2 ]6 }/ C: O1 L
#c::. L+ _; J9 F+ G5 M0 _
OpenCmdInCurrent()3 @7 i/ S5 s2 H
return
; ], S, f! ]. t9 F #IfWinActive- C$ X* f$ k7 i: q# @8 Z
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
; ^ a9 @4 f y) [" ]/ E/ @ ; Note: expecting to be run when the active window is Explorer.' I0 g0 d: `7 S P
;; P) T @/ t! R2 Q2 M7 {8 q
OpenCmdInCurrent()
w7 Q: k3 K. T. e3 \, \ {4 ?' K& E" d4 f: f
; This is required to get the full path of the file from the address bar0 s4 R1 |, z N! A3 t9 p# R
WinGetText, full_path, A$ O; i9 P; k# @" @
; Split on newline (`n)6 [$ }7 o) O1 R0 H# C
StringSplit, word_array, full_path, `n7 Z' z0 [; k: {, p% q' Y
; Take the first element from the array$ `8 A2 |: o8 @
full_path = %word_array1%
5 `/ r, ?6 [" t( b3 f ; strip to bare address
! y' L3 _& \/ q full_path := RegExReplace(full_path, “地址: “, “”)
0 t* n4 \5 v7 L' ^8 N/ @ ; Just in case – remove all carriage returns (`r). R9 l3 a: }2 r, I
StringReplace, full_path, full_path, `r, , all
% h' x4 T$ R) p; b2 |% R6 c7 Z$ w IfInString full_path, \* ^& O; J# O' [" _, e
{
& v/ t( E$ |; B. V; d2 q: p/ t Run, cmd /K cd /D “%full_path%”- d( r4 F& E' @* F+ P
}
/ Q4 B5 \- }- i8 V, R else( L) Q9 n1 I: G6 E
{2 Q. U0 G( q4 p0 [3 }8 p9 D/ H" u
Run, cmd /K cd /D “C:\ ”9 P4 g. p. N2 u3 {, s
}* X: u/ I* N" S6 h9 @
}4 k4 z9 A; g3 W) A5 n
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
e' e$ n+ I9 v: e+ j7 K0 { u& } 这段小代码肯能有两个你需要修改的地方: j% v0 j* w% K. P, ?7 \
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键; P, \! V0 h8 H3 x R
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “2 Q3 {/ n. V$ s! U
|