此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
7 u) X- e/ Y& Z. G 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
4 _* L' Q" |& i0 u, V5 ? 方式一:: v$ Z- X3 l8 _/ z3 {
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
9 ] g- w" a o% \3 \! e, g W$ D! i 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
1 A2 |! W3 F9 R0 M HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
! W/ x3 p7 T- r 方式二:
3 v9 q) @% d+ ~. M m 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
8 G, v* }$ h4 N/ K8 y SetTitleMatchMode RegEx
4 T- r u/ n4 d* d0 ]1 [ return# R) ?- U. R' _: H, b
; Stuff to do when Windows Explorer is open- C% j" L( u2 k/ M% F0 P
;
V5 m; g$ w0 j; {4 ~ #IfWinActive ahk_class ExploreWClass|CabinetWClass5 U" m( B9 N* p- G
; open ‘cmd’ in the current directory' w0 w1 C* u2 J4 `+ m* D$ d3 a
;2 F1 q) w' a# e& g6 {' K6 R2 y
#c::
& C7 u# u4 i: X OpenCmdInCurrent()
! ~+ h( [$ S5 C9 m, X return
1 u9 r) e1 i6 r1 {# E #IfWinActive
! n9 l, V7 c( @! x ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.# R8 d' ^# s1 B: o, k: [8 r/ b
; Note: expecting to be run when the active window is Explorer.1 a5 \0 [' d, ]4 |7 s
;
; P9 W4 Z% e& p4 ?( S OpenCmdInCurrent()
9 B) m7 m" l+ t6 g, n* T {
4 J* `+ J0 E; i* X0 c9 j4 H ; This is required to get the full path of the file from the address bar& e3 p9 t' v, b* {2 `
WinGetText, full_path, A# y+ M3 S* j8 B" v
; Split on newline (`n)( |- O$ } Z1 W$ P/ a( Z( g
StringSplit, word_array, full_path, `n
) Y* q/ c' M) z" U+ H; }: u6 ]7 W ; Take the first element from the array( l3 A+ G1 x* v- C' v
full_path = %word_array1%) L6 w1 J+ O2 E, T! k' \
; strip to bare address+ \- z8 l9 H3 ^) R; V j, I$ y
full_path := RegExReplace(full_path, “地址: “, “”)
( U" ~" v& s) J" n, k ; Just in case – remove all carriage returns (`r)3 d& u% X2 y, [- R2 c0 w D1 {
StringReplace, full_path, full_path, `r, , all
N+ l7 m' E( j2 V X% H IfInString full_path, \
+ R0 p# n$ n, I7 ?3 u, V {' C. Y. j, Y* h7 ?1 {
Run, cmd /K cd /D “%full_path%”
8 X' L, v, A7 N6 n) S( e }2 N- v# m% s- v$ O7 n
else) {: R- n* h6 R: O$ r) L3 m. ?
{9 w/ S2 R; k, w- d& H3 Q
Run, cmd /K cd /D “C:\ ”2 @" u! \& d) k% l) O1 ^
}
1 d, o; u+ [0 i5 Y }
$ a2 C- r$ c! u/ M0 A 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。8 K9 i, T) q- o
这段小代码肯能有两个你需要修改的地方( S8 F3 H8 l3 X! X- {- T/ s% G1 t( g
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
# y! K7 Z' R1 A9 n( d; ^' a. {- K 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “& Q" j& t: m* O# G* w
|