此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。: H7 W( |* p! W
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
* }( {; L5 U" |% s1 _# r 方式一:! j+ W9 J) h+ t! U* {1 ~1 ?4 I
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,8 L9 V8 S/ C7 ~
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和$ }- a; L, v3 U9 E
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。$ N$ o" r7 g! C/ _- h
方式二:9 g- G+ \$ ^) Y2 K
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
2 G$ g; {+ \- y* R) c( E+ D SetTitleMatchMode RegEx
3 p W R: t/ I return/ V, Q1 a8 }, ]) H$ q6 m
; Stuff to do when Windows Explorer is open, E& T3 t' Y! T
;0 \- I/ f. n. P S) J& ~+ F
#IfWinActive ahk_class ExploreWClass|CabinetWClass
" g& w0 W) {" I& W: y7 G ; open ‘cmd’ in the current directory
! G: u+ i+ ~9 D) n3 e4 b ;: e0 g A y2 \( P4 P4 n
#c::, C) W6 v" U5 s7 D$ j9 {' ?. r
OpenCmdInCurrent()$ Q; K) `8 e1 \3 T& H+ d$ B; I$ w
return
, x2 X9 Y' Y5 C #IfWinActive
8 G1 m( h+ x: L6 }3 c ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.$ M% _- p* J8 K
; Note: expecting to be run when the active window is Explorer.% W; g. z/ r# i8 m* R
;
6 X2 y" k- j/ T4 W OpenCmdInCurrent()' z* W$ j5 x3 T s+ l; q# M
{
7 u: _. t' B8 |, M ; This is required to get the full path of the file from the address bar7 V$ k1 j* z: C. c% n; f' b, R
WinGetText, full_path, A
( g9 S7 l* w0 b8 Y, T9 @! p0 X ; Split on newline (`n)+ d: C' q8 B8 S) E M3 e8 U$ I
StringSplit, word_array, full_path, `n! P; e" o/ k( p, `- [3 p! p! p
; Take the first element from the array
' u! K" I, m/ J- z9 n# h full_path = %word_array1%7 f# Z. L5 {3 w: n
; strip to bare address
6 y8 b8 t I+ ?1 U, i full_path := RegExReplace(full_path, “地址: “, “”)- `2 G% u% A* x+ B" Q
; Just in case – remove all carriage returns (`r)
) O o- e! z( f1 y) d0 P+ H. n StringReplace, full_path, full_path, `r, , all1 u' ~, }# O0 `; U
IfInString full_path, \) N. }# A' n# Q. E; d1 L7 b6 x
{
8 z3 `7 b; h4 k Run, cmd /K cd /D “%full_path%”
% [8 |$ k5 h" y- O* Q }
4 R7 F, x$ y- r. h+ Y else# Q: r1 {# ]7 a# {* L, M
{
3 A0 _7 c! J) j c' n Run, cmd /K cd /D “C:\ ”
6 Z6 L, Q/ J* W9 s' K; P& g+ [ }
, V% r9 g$ k" c V& c }# c% l/ z) g# |# J5 b$ P8 g
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
7 L$ C6 O0 ]- B) A 这段小代码肯能有两个你需要修改的地方
) e0 ^# Y) d% z) Z. v 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键& M2 p7 M$ U+ q& K1 Q
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
4 i: u/ f1 t" g+ H1 G/ ^$ W |