此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。; C, r5 g3 p4 m8 d b+ p! X
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。7 G4 h: ~2 N& Z9 m; |1 }) P3 _
方式一:2 B+ B& P) s X% @8 ^
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
8 w$ u9 ]: w4 q" n3 o2 B 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和8 \( H5 W6 b9 b$ w4 W( F2 L- |5 n
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
0 u* C& M# I7 ]+ P( @3 s: a6 R% R 方式二:7 Z p. K" K% O7 S# T6 ^
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:5 d) R6 |; U8 b' Z/ ~
SetTitleMatchMode RegEx
4 p& t- i! j0 S return
0 F+ _' u* S( e" p$ [6 { ; Stuff to do when Windows Explorer is open5 ~' E+ f( H1 D
;" R/ C: w; N0 {$ q$ C$ N! e0 N
#IfWinActive ahk_class ExploreWClass|CabinetWClass3 G9 u" z" Q& S
; open ‘cmd’ in the current directory
* B/ a; m1 G' j( s5 i% ^, O ;
5 @2 I( ]4 ~3 i- ]/ E: f #c::
8 l/ X: s! ]# E$ r" a OpenCmdInCurrent()
4 b2 R+ \% K2 e& ~3 t return5 w( n" g" m% s, Q7 t. w
#IfWinActive9 X. i" r f1 [5 H
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.5 ^% D! g8 n; @% d/ S6 ]
; Note: expecting to be run when the active window is Explorer., U( E H6 L) N- e; X
;/ `! M' ^' |8 c- L* w& c
OpenCmdInCurrent()
! W9 y" q" H% s" n# P. } {4 a# w0 b @' H( e4 ?# D* K5 ?
; This is required to get the full path of the file from the address bar- Q" W; S" p: S! H% C5 w
WinGetText, full_path, A1 i6 p, {% j+ v* W( p: f4 |
; Split on newline (`n)4 O2 ]8 d. c6 F5 p0 H9 s! C
StringSplit, word_array, full_path, `n
# h; B; i# n9 O9 L8 q! e ; Take the first element from the array
1 _ G( H/ L: s! r0 `0 A full_path = %word_array1%; W! [* P5 ?; P7 D7 h* p& r: r
; strip to bare address# P w! L6 T' \# h' l, r+ Q2 r' P
full_path := RegExReplace(full_path, “地址: “, “”)% w" h+ f3 d: s) X y
; Just in case – remove all carriage returns (`r)
+ b# o1 s/ L9 x, l( P+ l! E* M StringReplace, full_path, full_path, `r, , all* x$ D5 [" n3 a7 l, n$ M+ N$ I' G* {
IfInString full_path, \" C J3 u9 l6 B5 F5 w, k8 `
{
* N/ r9 Z$ M0 j# I Run, cmd /K cd /D “%full_path%”
6 Q8 }! r0 j( A. D }
# v* ?8 M' w$ e1 g8 t else
% T7 ?$ i4 s( j U8 C/ J {
' t2 m: P- r3 n6 g, p: d Run, cmd /K cd /D “C:\ ”
, X" l( C5 s3 Y }
- o8 M( ^( J& u3 z* F6 i! r4 g, d }
( Z0 H" \4 b- Q3 ~' J! ] 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。+ f* H& q* W$ A' U
这段小代码肯能有两个你需要修改的地方
) P1 ]% v: `) l; e% v4 j2 s% K 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
, P9 K4 X7 @" V8 o$ l+ ^: d ` 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “9 a! x5 O9 E \6 g- S
|