此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
$ i1 `8 g* e4 ]) ] 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
/ B" s& @1 A7 R5 _; f" ~: B" } 方式一:
2 k' w" G+ h' r" f, s/ @' x 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,: L# x* k. B* z: R. N3 v7 i4 D! l
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
2 V0 y2 W8 k7 e% J/ ?, ~; d HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
7 D: S3 x1 l) ^7 P6 U9 d 方式二:
/ `: l. z9 n5 C' \- X7 V 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下: N: S. g: s; n; R
SetTitleMatchMode RegEx
: L* A. y. ^' \) J# J3 v" F return
) [& U2 A$ Z% F% c ; Stuff to do when Windows Explorer is open
N4 _" b# u b9 U' ?# f- \$ K ;
r! w! C$ `5 o& J0 X6 s #IfWinActive ahk_class ExploreWClass|CabinetWClass6 k3 z! t! Q+ C6 \& ?
; open ‘cmd’ in the current directory
% Z2 K3 e- |5 ?2 r/ ^ ;
! Q/ O7 `4 N, i7 _ #c::
( w& s; y! ]+ U0 R9 v+ Z2 w OpenCmdInCurrent()
& F; z( b( x2 E4 Q3 N return
/ b( ?) f$ N5 ]5 ~ #IfWinActive
. Z7 F7 {7 ^# F( z. w' v& W ; Opens the command shell ‘cmd’ in the directory browsed in Explorer., ?5 a C- h" X2 d* G1 N. O
; Note: expecting to be run when the active window is Explorer.
) _* u( M4 g- @( C0 E ;
/ ~) z8 I' t: M9 l/ [' O9 a" e OpenCmdInCurrent()
+ ]+ f- N: W1 J: S$ N {4 B1 x7 H/ r! J; y, f' Z
; This is required to get the full path of the file from the address bar G) l7 l8 k" B5 _8 I+ } `: L
WinGetText, full_path, A, ^ l7 T$ Y/ U8 c6 A- j! m
; Split on newline (`n)
6 c( L3 Z! E* {$ J StringSplit, word_array, full_path, `n- _# V; H+ O3 y, F8 ~
; Take the first element from the array8 {4 U! S: l8 Z/ J8 e5 V( z
full_path = %word_array1%
4 ~) R3 A. x; I0 ?; ` ; strip to bare address. t; R- O) X8 v' O% U
full_path := RegExReplace(full_path, “地址: “, “”)
9 i2 j4 b5 ^/ o9 ?0 a ; Just in case – remove all carriage returns (`r)
! T A# A) ?( A: w) \- Q( Z& W StringReplace, full_path, full_path, `r, , all
|# W. Y! L: N. l. f4 z IfInString full_path, \
% x- n( g# d E1 ~9 J, t4 v {- b3 ?3 Q6 I# P) T! a; O+ w5 }
Run, cmd /K cd /D “%full_path%”
0 H. C, I& V: l6 @+ \ }
5 F" Z4 z s& H: l( ^ else
6 n5 y. \8 o$ I) k; a {- Y3 o9 ?) s' ^" d5 ^) s( V
Run, cmd /K cd /D “C:\ ”
8 I) c# P% u0 n9 Z }6 c$ L# I; n: ]- x+ t
}2 f% o% {9 G, Q' }
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
" r. o- B4 v8 m! u. S D 这段小代码肯能有两个你需要修改的地方4 v9 l6 r7 H! n
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键. M) {; w0 i9 z. ~& O
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
( {. [; F. b# _+ O6 Z; w |