此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。$ S/ A- }, a1 e' y$ P P' E
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
e, q/ R- M2 E2 h+ X1 ^ 方式一:
+ V' v3 }. Q/ R X1 S& T3 F# ?2 w 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
: @) T" l1 P4 @6 ?, @ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
& X5 U( z1 ^% Z1 k% i3 w HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。* Y! Y6 U: e& F6 r$ V8 O
方式二:
; y% C0 X4 E- R3 W 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:8 e, F6 f" R0 L. D: X4 X0 ^
SetTitleMatchMode RegEx
% w r9 D* K6 T return* { M. b+ g% G! [! l; g5 S! d
; Stuff to do when Windows Explorer is open
H/ A! N- d! f+ h ;0 _0 j x9 m0 ~% S0 [- j- w" i8 C( S
#IfWinActive ahk_class ExploreWClass|CabinetWClass
- D: O8 A8 t. k3 C* [ ; open ‘cmd’ in the current directory
% O+ u7 D, M8 E3 D1 d# R ;5 _* k8 I; r/ b4 {2 c5 _
#c::
) t9 W6 c+ a G2 O) v* e1 k OpenCmdInCurrent()7 O5 g7 u' w& ?. e5 K( U& c" ^- D
return
4 } m$ {. _: v #IfWinActive% Z: T* E. D1 Q" ^# @9 N
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
$ T( D/ l- z3 f! g7 r L- ` ; Note: expecting to be run when the active window is Explorer.
7 `& z# |/ k' r- A# @+ P( q ; m( p% J: d+ s. U X
OpenCmdInCurrent()
& r/ O) y W l/ k; P {
+ b0 x1 {8 w3 ?6 H; a ; This is required to get the full path of the file from the address bar- z$ x- _* `$ f% G2 t
WinGetText, full_path, A) k8 a H/ S! L2 ?& A, R' I" ?. L
; Split on newline (`n)
1 k5 B2 q- L$ s; A0 \0 n StringSplit, word_array, full_path, `n
6 N; k# d9 e' b( W9 q& t3 s5 M ; Take the first element from the array
# z9 O! {) g; F& v# N( @ full_path = %word_array1%8 O5 `5 c! t, m" i4 Y% N0 a" |
; strip to bare address
( E% F4 l/ S7 ~4 i' d. J& B full_path := RegExReplace(full_path, “地址: “, “”)
d+ C, t* J* } ~ ; Just in case – remove all carriage returns (`r)
' }- @ H2 H& y$ _ StringReplace, full_path, full_path, `r, , all9 N, t2 M, D/ O- `8 @
IfInString full_path, \" S. \4 e' y) \
{
, B ]; v7 B1 U+ k Run, cmd /K cd /D “%full_path%”
: |* k& v6 O+ z }# G# v7 k$ d; A$ c$ K; {: @5 s
else
1 T) W$ b2 T1 @7 y) x, H8 C {
Y! o; {# J& Z) L Run, cmd /K cd /D “C:\ ”3 B8 |' V# c# V+ S9 [ c
}$ o3 G3 q7 B! _/ E5 D
}
8 I- u' u8 M) d 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
3 d. y2 g" Q. \9 l* b 这段小代码肯能有两个你需要修改的地方
0 s4 @0 j% J5 K0 ~; D% }, M" I6 b5 Y 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键) d& N& X$ T2 o2 H( e3 f8 }
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
" k# \9 L9 X) I1 n4 l: r% t% i |