此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。 u( \& r5 t$ ?5 R# A3 P3 \$ _
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。4 M& V' V& F# ^5 p6 c# i
方式一:% c ?( `. ~/ ~6 B; g: y/ D) w
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,* Q) [5 b; A* U; k h7 {' d
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和" X! I$ P/ X& B8 P
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。* ^7 c) F2 M7 Y( ]+ {) Y8 k
方式二:
. N1 F, F1 M; i 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
; L- b& X0 k8 _# c$ U" n6 G6 x) Q SetTitleMatchMode RegEx
6 L8 r N5 \& |# S: M! d; a return8 i2 z, W% I2 {9 |
; Stuff to do when Windows Explorer is open
4 Q/ _# k2 o/ U' @8 D+ s9 C/ T) c& o ;3 y1 V7 B+ d$ z* P5 W7 n8 v3 R ~
#IfWinActive ahk_class ExploreWClass|CabinetWClass) {' v( s2 ~0 B- q5 |9 p2 m
; open ‘cmd’ in the current directory
% i1 U; L' j3 | ; p& Z, K: b: x) g* ^6 w
#c::
3 f+ _6 U6 z0 F X8 \$ `6 b. J t OpenCmdInCurrent()
8 N& ^' Y5 A# @ ?- `7 P return
2 \# K& j% ?' ^1 ]8 @ #IfWinActive, C9 J6 E7 j2 I9 M
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
' K; ^ N6 q3 Y) p! @3 c ; Note: expecting to be run when the active window is Explorer. E8 S5 G3 B7 E* ], ]
;; |6 L4 H/ |- ^, e
OpenCmdInCurrent()
5 ~0 O! N; k l7 e! ?; B1 s {. v8 ~/ f- i5 C1 c
; This is required to get the full path of the file from the address bar. o( _: k* C# Z8 U' u6 u A( U1 r
WinGetText, full_path, A
# y0 F0 t0 M6 ~9 w6 F) k- ?" R7 @! r$ h ; Split on newline (`n)1 d5 k0 E0 @; d3 y& d4 L' x1 u
StringSplit, word_array, full_path, `n* N9 J" V0 X. _1 K/ L$ \
; Take the first element from the array0 q' l' Z" s/ K* f( o4 t
full_path = %word_array1%4 K- n, j0 h4 t- r f& g* N
; strip to bare address7 p' m# v' |2 w! z0 F/ O
full_path := RegExReplace(full_path, “地址: “, “”)
5 `3 P/ V5 {6 h( H ; Just in case – remove all carriage returns (`r). U" Y% y0 D. e3 M7 `7 C( s
StringReplace, full_path, full_path, `r, , all
5 K8 \6 J8 k# Z" T d IfInString full_path, \
S$ F1 V3 d5 V {
0 s# N/ `; v) R# q Run, cmd /K cd /D “%full_path%”
( q$ o" m) i. q3 A) M }& w2 p( p+ s$ B# Q
else2 r9 W+ Y# y+ j) z1 ?, Z
{! k5 i0 U8 B' M& V! y4 b
Run, cmd /K cd /D “C:\ ”( K* V4 D! x& u3 L9 l- d
}
7 J6 F: n7 _7 p% j- i9 [! R' I" { }
- T, \4 E$ x1 Y/ P/ `8 b 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。* h+ i$ D& l; M6 P
这段小代码肯能有两个你需要修改的地方
* {: O- a# u: I& @% N+ ? 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
$ d; i3 o- X8 Y( d 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
" Q9 A( e3 X$ W% L! q- }) @ |