此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
- O+ o: L+ S+ c6 J# X 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。6 |7 H W1 r. p, N" I4 E0 A
方式一:1 H9 ~6 G: r+ [2 ]8 ]
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
+ j1 {$ ?* |" r) B8 Q1 O/ I$ T 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和* ~2 W$ Y/ g2 I) w
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
4 M1 w# m( l& E5 l6 u* w 方式二:
/ P S" @' W+ e G 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
! f$ p% x6 J5 Z* t2 r% M SetTitleMatchMode RegEx
' s; y# {% M* Y& ]& W. |* m3 o return U% p4 ?- n/ t$ K) v0 P ^' X
; Stuff to do when Windows Explorer is open
" G2 U6 \* p: b; M1 j ;4 M! o7 C3 u% s- r" d$ t
#IfWinActive ahk_class ExploreWClass|CabinetWClass
+ e! c- r1 W5 o* p4 x ; open ‘cmd’ in the current directory: a* J+ M, x( X5 M; { Z+ [
;
0 N% o# K u) {# W7 N$ n0 x/ { #c::
0 c* s! m# s0 n% p+ I% i$ I; e OpenCmdInCurrent()( V8 Q0 T8 W5 w; m2 r/ ~/ W$ f
return
4 x# f6 H) s: m #IfWinActive( ^; d* Q: t0 }+ L* A1 Z
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
: x- U3 E& ^+ N/ M+ z: w3 N# m ; Note: expecting to be run when the active window is Explorer.$ j4 t+ Y8 @! _! d
;
; \% t# ~+ Z- c0 L. w OpenCmdInCurrent()! ]7 n$ B* S9 X
{
$ M; ?7 Y8 V+ U" V4 w/ D' r& C ; This is required to get the full path of the file from the address bar
7 I/ u; g+ g6 U5 K, Y WinGetText, full_path, A
% A# E2 ~/ t+ H; N6 F4 L ; Split on newline (`n)/ T2 C+ Y4 P: ?1 _
StringSplit, word_array, full_path, `n
+ D3 V( P& K: D, l/ v ; Take the first element from the array
( P# D! M& W# z0 F4 z full_path = %word_array1%
- G7 Y5 k" i$ N7 q ; strip to bare address
4 F9 a# p/ s! A3 @; k: b full_path := RegExReplace(full_path, “地址: “, “”)* ^6 ~* Y, t+ ` l
; Just in case – remove all carriage returns (`r)1 ?/ j) j/ O! Z5 \9 X7 L( r4 n
StringReplace, full_path, full_path, `r, , all
6 ?9 J' m8 ]8 [7 w5 E IfInString full_path, \
" d% I M+ ~( Q7 g {
% s& p* O7 ?5 }2 U5 E5 b9 B9 l Run, cmd /K cd /D “%full_path%”$ d1 S$ }9 f) a1 e
} H: H1 {6 n2 v' [. k2 j) X e
else
* O" F- f% Y f {
, z: d4 y% \2 [2 e# C" N. S Run, cmd /K cd /D “C:\ ”
- c' ~: N3 I. M' {" ~0 | }/ i1 x; X& } U+ X1 g- ^. W
}& Z7 l6 L" i" }. `# n$ I5 A" Y
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。. P" a! q9 F: R# K
这段小代码肯能有两个你需要修改的地方* o& ~) |. O) [! V4 i% a
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
7 y' ^- e: ~9 P2 L ?" r 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
- z: ]9 t0 [( l1 K; F" K# c6 N |