此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
# g- B, X, C/ {, O t- v 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
0 ?) X! E+ w: @# f/ y& ?3 ?- } 方式一:6 [: U2 h2 r4 Z: T" ^' i
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,9 G8 |- T! }$ U+ R" n( a$ I* z- x; Q
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
. {* V% y, L7 l3 W" k5 o: M HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。/ t5 S2 c) f$ ]# ?. R
方式二:
2 }% W z5 V; m+ H 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
# \; e0 h# E! K# U SetTitleMatchMode RegEx
$ X- o+ H! f5 R0 f e8 K3 [ return* f& v) v% ?' R) o( }. T! t
; Stuff to do when Windows Explorer is open
* W3 m% I5 ?8 d ;! |* s8 f8 L. c5 L+ M' {3 O. \: g, f6 _
#IfWinActive ahk_class ExploreWClass|CabinetWClass& H- L& V2 @( Z: }% L9 c6 x
; open ‘cmd’ in the current directory
9 o1 O* `6 B" t ;1 J1 d( P7 C; m2 f" L, T& I. `
#c::
$ S) Y8 p) r% [5 E4 h OpenCmdInCurrent()
* A4 f* p3 ?$ P% Y8 e return
z/ L) m. J/ h+ w' e: o) Y #IfWinActive
! w" c; i( G" W) S4 L9 G( _ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.2 U7 F h1 T4 h; A: [
; Note: expecting to be run when the active window is Explorer.+ \: y# O, j( H$ V
;# K7 V3 c" I- }; }1 v+ g- ^: S- v$ ^
OpenCmdInCurrent()/ D( `9 a6 q7 O* x0 {
{6 v! j5 L5 s3 ]' p% Q
; This is required to get the full path of the file from the address bar) m1 E! p# N: @4 j4 i
WinGetText, full_path, A
% l0 s' e6 L) v7 W ; Split on newline (`n)
) G; E8 \+ U+ C6 b+ ]! ]/ } StringSplit, word_array, full_path, `n
7 q$ ~! ^9 ?# S ; Take the first element from the array
7 [6 s5 M- b; k, W0 d full_path = %word_array1%
4 G( b* k7 i7 _& F4 m ; strip to bare address! `& D9 O D/ S( ^% G
full_path := RegExReplace(full_path, “地址: “, “”)
- F: m1 F5 r& I5 X5 a( k ; Just in case – remove all carriage returns (`r)
# |% X" A, ]2 `) P* C0 d StringReplace, full_path, full_path, `r, , all
7 }( ~8 Y' c$ n$ E/ K8 J IfInString full_path, \1 B0 K) j2 }1 u* }) @
{
. A0 ~% b# G' r; u& b0 t# L- x Run, cmd /K cd /D “%full_path%”$ l6 W% R N ]) p) S1 x
}( |4 b" D6 `6 J _+ q; w
else- y' q) j" P) d$ T
{2 F1 F* h W7 g5 J: s* x" q" |( {1 p
Run, cmd /K cd /D “C:\ ”
$ S7 j+ u1 G) V7 h3 b# x: K }* T! p9 O' a8 E
}1 Q/ K! N6 _. u# e" ~7 @
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
. q t0 W' K1 o8 p' a4 a 这段小代码肯能有两个你需要修改的地方4 l# j. N) g: H2 w- f5 u
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
0 s. P# x* x0 M) [! ]5 X) a- x" D 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
. Z; \5 W+ a! `( h* E- F |