此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。$ U/ f4 T* H6 ?2 N9 a: y
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。3 n- E7 H; \/ V5 | u A) c' I
方式一:
6 d" y/ R0 R% F8 [- z; [ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,( S% @; U1 }2 ~1 m( w7 f
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
- Q) y# w+ G3 G; \/ H2 F HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
M2 j% E7 Z6 c 方式二:4 V; a1 l# [0 x5 v* X
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
, @9 }6 u6 y) Y' x( q$ T) P SetTitleMatchMode RegEx, g [8 c2 |4 Y4 Q; }& t# x& ]
return
9 f% L s7 f* Z2 `2 G- Y% p+ |4 B9 a ; Stuff to do when Windows Explorer is open
/ Q9 G1 \# W! o: k! l% { ;
1 n$ j, J9 i/ t3 K4 [2 t! C% i #IfWinActive ahk_class ExploreWClass|CabinetWClass& G4 M) r. H* B4 `9 i
; open ‘cmd’ in the current directory
3 C' f7 L$ O: Q) `: U2 Z4 b, k$ t ;
3 n% P- Q; ]) u8 Q8 B% r! M8 b #c::' m+ r2 E. z! Q6 F c+ r5 o
OpenCmdInCurrent() [( i* o4 U$ o+ c }
return# r; G! K ?2 ?, Q; v+ u( g/ N9 Z) F
#IfWinActive% M1 g `! V0 M. W1 I5 N5 B ?
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
3 ~, |% z) K0 y* e4 x& m5 ~ ; Note: expecting to be run when the active window is Explorer.- M8 u6 \* q; ^1 ^, Q
;/ T' f# P/ T9 w$ [( }
OpenCmdInCurrent()
$ O8 C- y5 x9 k* r# c) J {0 l# B8 p, U. f/ J0 _- c. ?
; This is required to get the full path of the file from the address bar
" D* i& Q8 u9 x" I$ y: V3 _% M, g WinGetText, full_path, A$ g; Z4 w: K. H
; Split on newline (`n)7 M9 h) i, z- K, Y6 U
StringSplit, word_array, full_path, `n
# k* S- s2 z4 |+ O ; Take the first element from the array& I6 }/ M: `: [9 Q. E; ]& o3 g
full_path = %word_array1%- `5 b$ I! h7 |% b0 ?
; strip to bare address
' E/ p# b: E- ~3 Z7 T# q full_path := RegExReplace(full_path, “地址: “, “”)
$ J/ V' E2 R. o* E( d& R ; Just in case – remove all carriage returns (`r)
# b2 x& m9 Y+ }0 E. x% [8 r9 N StringReplace, full_path, full_path, `r, , all9 B2 r. v' e1 H8 L' b. z, f
IfInString full_path, \, q- n5 E# H( B5 Y, z6 t; U4 x
{
7 E% G+ Y {2 t" E4 e. u0 T Run, cmd /K cd /D “%full_path%”
/ f3 }; `, w4 h9 U3 f0 G5 N }0 h8 [& p$ k+ J
else5 q$ p1 H& H9 @! L" W+ t
{
) |/ j3 n( a+ H3 L5 ^. b) u! ~8 c Run, cmd /K cd /D “C:\ ”* }) n7 Q5 F( G% P0 R
}
1 F0 _; @" q! x+ Z }! Z: ^6 g3 Y2 H7 S5 J! L+ {
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。% F# r: U$ a4 i; A
这段小代码肯能有两个你需要修改的地方
8 @- ^$ X* V. q# t0 g 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
" J: _2 C. m& I 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
- L; A0 Y* b0 `! u% S# Z |