此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。* u4 R1 a! B" V% ?
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
i- z/ Y/ k7 _ 方式一:
; f; U2 N2 i/ k( _ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,/ E4 a7 T* j) ]% T x/ I4 S
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
7 l/ I; m! j1 z M0 H$ m6 r# ] HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。/ f, C r. W" o8 A' H
方式二:
8 u5 R' b6 r+ C; b2 y 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
# {, W9 @, K4 i SetTitleMatchMode RegEx6 m, m$ e! K! @3 N
return
1 y: |- T( Z8 T6 V) h h' G% q9 h. S ; Stuff to do when Windows Explorer is open1 a7 n$ ~7 D( V! X S% z D; K
;
- ]# y6 m+ ?; H4 B6 f; Y #IfWinActive ahk_class ExploreWClass|CabinetWClass! [" P% d4 d' t1 \2 i: D6 q5 G" B' h
; open ‘cmd’ in the current directory
9 M5 e& e1 n: Q7 U ;
2 H& t# b7 G3 B) { #c:: k6 H, ^3 P/ A3 ]
OpenCmdInCurrent()( g$ O1 I, F4 [" Z
return5 C& E; ^# e- ?. u
#IfWinActive
3 y7 I# o! J( c) X6 y/ n9 \ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.7 z7 s; j' R2 n! I( j& Z
; Note: expecting to be run when the active window is Explorer.5 F0 A" _$ P% S
;
! D9 i: E; ?7 ~$ F) F OpenCmdInCurrent()4 F! c& v" u/ A3 _& P. Z' i
{2 J+ Q5 ]# v/ O w
; This is required to get the full path of the file from the address bar# p$ M' P+ T6 r# w$ @1 Y0 Q+ T
WinGetText, full_path, A
8 l$ o$ t, D2 |' b( j ; Split on newline (`n)
3 ~& A2 n4 E5 j% Y StringSplit, word_array, full_path, `n
" E- P( v2 R3 H) U# P ; Take the first element from the array1 v S3 h% K4 D1 W+ ^1 D- M
full_path = %word_array1%
; T B3 R. N2 W ; strip to bare address: Q( O+ N$ A% {% _/ f5 M1 @
full_path := RegExReplace(full_path, “地址: “, “”)" k1 @& B3 U7 u4 a# v# M
; Just in case – remove all carriage returns (`r)
0 Z3 [- d0 M2 m' R& ` s StringReplace, full_path, full_path, `r, , all& t, O( y" C, p
IfInString full_path, \
# _- ]6 R& @4 i. d* U3 [: c. S, h {
0 ~% {. d" R& A, t( f6 i( l Run, cmd /K cd /D “%full_path%”; M: ^2 F7 Q6 p
}
9 N4 w D# o) S! ?6 M else
+ C6 C5 Z( a1 N6 o$ k0 b {: K' e) s! \& f/ e, w
Run, cmd /K cd /D “C:\ ”
7 n) m: \$ h7 A2 x' J }
8 h2 d+ M+ ]7 i+ L0 ` }
% g9 }5 t4 Z3 t3 F 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
5 G0 f; |0 C4 m" Q) i. L: P4 c1 e 这段小代码肯能有两个你需要修改的地方
4 ~" n4 m+ x9 ]$ v# u' W 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
& g- G) u% S! B, H# \9 d 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “8 ^6 _0 P0 l r8 k `+ q! v
|