此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
- A7 @" W! D' q 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。, a' L- c& g8 _5 O8 C8 h1 Q4 B
方式一:
2 W% o# `6 r+ A, `9 J% o 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
3 S8 q) g, M1 B 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
- |! I8 T: s" c2 k HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。' y4 }* H* J# O3 A5 j# W1 s
方式二:
9 I' n7 `3 B$ N. b% z& ^ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:' O& D5 G9 `( H* W
SetTitleMatchMode RegEx: s' X4 V. ^% e% }1 K
return
k3 j" W4 Q: X: C: i. {+ r ; Stuff to do when Windows Explorer is open
. o: _& r& Z7 p$ { ;
0 O" `7 H+ a9 ] #IfWinActive ahk_class ExploreWClass|CabinetWClass4 W% T6 }( O2 [" L9 p+ o
; open ‘cmd’ in the current directory' v7 p! M7 J8 `4 g
;* N) ?& ]+ M* b3 {
#c::3 |) o5 H* R7 s; M
OpenCmdInCurrent()
% X, P' r1 o( K _' _, h9 B! ` return
- D; a& ~% h0 U #IfWinActive0 c2 |) g' E2 w8 S8 N7 Y
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
2 `% K& @2 O6 }7 r' I ; Note: expecting to be run when the active window is Explorer.
! y, s, Z0 t- ~) Q; k d; a ;
0 x S8 w' W" q OpenCmdInCurrent()/ C4 d& o" I9 e8 R
{9 l& L7 @7 {4 D- m: [0 l
; This is required to get the full path of the file from the address bar
( Q2 m/ ^$ ^8 w# i7 i7 J1 c WinGetText, full_path, A5 `; X! ]3 J$ q# u3 f' Y$ x
; Split on newline (`n)
" ]1 ?. s I6 W% y2 I1 O, I StringSplit, word_array, full_path, `n
3 a F$ k& }2 t' P ; Take the first element from the array
3 K7 w" m% Z2 }! m- Q, s, W full_path = %word_array1%" y. |1 t4 H& h$ f% @
; strip to bare address
4 v% y E2 O6 A! A& Y full_path := RegExReplace(full_path, “地址: “, “”)1 B" i$ _% u$ x: \. o" p) m8 ]
; Just in case – remove all carriage returns (`r)
0 y& i9 x6 I$ |+ W StringReplace, full_path, full_path, `r, , all
" a9 v( i7 F8 Y: H: R IfInString full_path, \& r) R, o$ @6 k3 f. W
{
2 [5 `2 g2 X+ p5 x2 e* f0 j Run, cmd /K cd /D “%full_path%”
( c/ l: T" ?, ~9 X1 \- J } a8 D* a5 ^' Y: k5 a. f
else
5 D5 x0 s! C2 z {
: w4 W" d! V- @. ^8 @ Run, cmd /K cd /D “C:\ ”& ^ z I$ D8 B
}7 @( W0 G6 V5 y( `. F
}
: a( {5 e) w% o 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
* Q7 U; r1 W3 w3 q0 S6 [ 这段小代码肯能有两个你需要修改的地方
$ V1 D5 v& ?0 a' t% m' n, i 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
o5 c6 \; g0 D$ f) w 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “, ]6 m# s8 V# b4 h; j
|