此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。8 g* F! \( G$ n9 |
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
! d1 a! g/ [3 x# e7 z7 i1 \0 v2 P 方式一:6 T" y; e' C$ N& e# U: l
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,$ _, L# x- u- D% v
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
T! ~3 g8 w" z5 k HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。8 N1 i6 R2 ?7 m# c
方式二:
5 J6 w& B8 h$ G& f/ i% Z 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:8 L, f. P0 x; u4 d
SetTitleMatchMode RegEx
3 B" j/ r/ `) u return" O( J+ y) S% {" V
; Stuff to do when Windows Explorer is open8 b5 b3 v$ x/ G# Y- K1 o
;
i4 l4 M& X/ m# L. |7 \( u #IfWinActive ahk_class ExploreWClass|CabinetWClass! U1 k/ s* q+ t! C& ?; o
; open ‘cmd’ in the current directory
0 [6 C5 \, F# H. V1 D$ k+ _ ;
- k0 q3 a4 i! W( q #c::. a: S, J+ t9 {9 y8 a
OpenCmdInCurrent()3 P8 i6 E R) Z6 T1 i$ {2 z
return
4 C9 }) x1 g( C* Q# a3 D4 y #IfWinActive! `3 ^/ k( s0 }; O
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.$ d! w' j% @. G) R! y
; Note: expecting to be run when the active window is Explorer.& Y, g$ V; C" h. T2 A( X4 }
;
8 o, Y' U( ^$ E) q. _' n$ \ OpenCmdInCurrent()8 U Z! d$ t3 ~: {8 s
{5 W# m$ {$ q5 J( Z
; This is required to get the full path of the file from the address bar
4 p- {/ R% E. @/ i( O, q WinGetText, full_path, A
4 f$ o8 ]+ U$ @: y; h ; Split on newline (`n)
0 Y$ \8 Y$ g# l( z# A: i StringSplit, word_array, full_path, `n, J2 e- Y9 Z; V' x# a' F
; Take the first element from the array
" q& r5 s; N: M, b& C6 S' z4 G full_path = %word_array1%6 r# ^8 r3 \. W) K( q5 j2 l- g
; strip to bare address
3 s0 a8 V& F; d, W1 M! s full_path := RegExReplace(full_path, “地址: “, “”)
( J9 O- i/ E) h$ b4 n: z& @ ; Just in case – remove all carriage returns (`r)
8 Y8 C8 G, h; w( c, O1 O, | StringReplace, full_path, full_path, `r, , all
7 |3 k$ _0 ]( ~/ F$ l IfInString full_path, \
: B$ P3 \$ c5 E1 C {% _6 a' e% }% |; w
Run, cmd /K cd /D “%full_path%”
; O3 i( ^; v) v4 U; i }
^9 |+ Q7 \8 W# \3 d$ ~ else, g; S! j; ?6 Z7 n6 m& j- e7 r$ w
{
W) G' O3 N3 d3 e6 _ Run, cmd /K cd /D “C:\ ”
. X3 J, ~( h+ D }
' c9 [$ U% r% a) u! A: v5 [ }1 H/ Z; U/ ]8 i9 h
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。) C# Q6 w2 W0 Z0 `
这段小代码肯能有两个你需要修改的地方- T2 Z' u+ c, V% W: Q. {. n, O
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键3 z {/ }, {" O' y
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “1 |! M z4 y0 n
|