此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。# j- n/ E" W" o! l. m' q
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
) z9 `+ L0 H) W P 方式一:0 H3 n; U; S+ R
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
. ~5 M. y X/ @, {9 l 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和: r- `* u0 [$ c. f
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。, Q+ l5 I- I8 |1 E" q
方式二:
3 @/ F3 j) I* R; d6 ` 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
7 d: S4 z- g0 T+ f1 w SetTitleMatchMode RegEx
: e) H @+ Y6 ~0 [: L return
2 S/ r A* P* o/ q* T4 w& _ ; Stuff to do when Windows Explorer is open) o! D" l6 Z9 d; _. v; E! x1 I
;
. {% k# d/ ]- a, X #IfWinActive ahk_class ExploreWClass|CabinetWClass! Q0 }7 o8 O$ j3 ~( Z
; open ‘cmd’ in the current directory9 s: [/ |5 c& I9 I& z0 D
;
' Y3 I: I6 R# S+ k1 o: T; r$ N5 g #c::/ i# T5 Y9 S) F( |; Q
OpenCmdInCurrent()
8 d, O* g2 {$ d. { return+ R8 ~. y8 ]& Z' L# N8 ^
#IfWinActive
. X- k4 _3 h& ]2 F+ b ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.; x/ ~) I- X a1 R8 z
; Note: expecting to be run when the active window is Explorer.9 _8 t8 J0 d% P3 g& v5 {
;
1 z1 ^ L: L6 [6 a1 ^ OpenCmdInCurrent()
3 X, A1 p& U. U& K# K3 M+ W% [: C- {8 `2 b {3 D9 H$ N) j) ?+ a2 W
; This is required to get the full path of the file from the address bar" n0 Q! w; k8 H: M1 l8 ~, y) q
WinGetText, full_path, A# \+ x+ i0 w2 j
; Split on newline (`n)
: j4 j c" q0 D) c* y StringSplit, word_array, full_path, `n
" S" E& Z' [' C ; Take the first element from the array
5 [& `' I2 ~. {6 F: E full_path = %word_array1%
3 h2 L% r5 [4 T ; strip to bare address& }& G6 O* n K& L8 |! W
full_path := RegExReplace(full_path, “地址: “, “”)$ D0 k3 f6 a# ]
; Just in case – remove all carriage returns (`r)
- z( u2 e: V4 l$ w StringReplace, full_path, full_path, `r, , all
/ h0 [ @* R/ y3 U: D: f9 @ IfInString full_path, \: g% } [6 H/ u6 V9 N
{& y. w4 b0 j. r& T
Run, cmd /K cd /D “%full_path%”8 ^3 Q/ d: a, C
}
; t* o8 ^# E; l* ^& W; x P else
# ]& R4 L& G: L {
1 z- K+ ?- E, h& M/ W Run, cmd /K cd /D “C:\ ”
6 e3 x9 i+ J4 w. E) p }% m9 N; @5 X) r6 R9 f) W
}+ b2 C; L; F+ T# \5 b& U
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
# S9 [5 n# [9 s3 ` 这段小代码肯能有两个你需要修改的地方% e8 H; ?5 L$ m
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
$ w; s& v* h2 s* R* I; ^* r 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
# w( d- N5 y4 c* C. Y |