此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。- x, v9 s6 A) T8 \% u
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
, U( S2 n) E! \" l6 d! I5 a 方式一:! P0 a. v' C$ n* Y
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,- ~0 A1 s$ D. E9 X" C( G: y+ y" ]$ e
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和$ C( u0 G0 S# G j& J1 Z4 c+ |
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。8 [6 B# ]2 i$ h. e# H( ]
方式二:
+ _# D) v; {; I+ P( Z 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
( s2 V7 G- X5 k( ?' A& j, R! |+ ~ SetTitleMatchMode RegEx/ Q2 V* m- ]' P! {0 J4 [2 O
return z9 n) @7 D/ K2 F* T
; Stuff to do when Windows Explorer is open- v$ x5 N5 D% C; H7 w
;$ Q1 w1 s2 {* M# _) H1 b3 {
#IfWinActive ahk_class ExploreWClass|CabinetWClass! d% ~* g2 v1 N* D
; open ‘cmd’ in the current directory
2 I. H- Y, m# Q ;9 \7 K# v, P0 f! c; ^4 s) V! u8 H
#c::( L3 a: |% @1 M- v) n
OpenCmdInCurrent()
$ }* u; ?$ j: x0 z: |+ t return( [+ `: B0 W! y% b
#IfWinActive0 o7 p1 d) _4 {& z+ r7 \
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
% N! O$ H' V5 v$ X+ [0 ] ; Note: expecting to be run when the active window is Explorer.
: P' x5 J" u' R7 E ;
2 D6 v) O4 J* K" ^ OpenCmdInCurrent()- ?* q& t1 r5 b; D0 Y8 }) f2 a* [! |' b
{
( b5 K$ t6 d8 u8 C ; This is required to get the full path of the file from the address bar
: Z. o. e2 v4 g: ] WinGetText, full_path, A
3 I" t% K: u0 K. Z ; Split on newline (`n)1 y9 Y# @4 ?- d+ S9 J0 b1 Y
StringSplit, word_array, full_path, `n
* l! }7 Q! j- e) A- A ; Take the first element from the array
4 ]* L& R6 t- P6 [, G8 L1 P6 U: X4 v full_path = %word_array1%5 S7 w8 Q& m# Y3 `1 t3 d' p2 r
; strip to bare address
$ o3 K, }) k+ { full_path := RegExReplace(full_path, “地址: “, “”)
% m5 m$ M* A# W: c' q }# n ; Just in case – remove all carriage returns (`r)
' Z! r6 m/ q6 M- s9 a StringReplace, full_path, full_path, `r, , all4 u* r: s% H" M/ ?
IfInString full_path, \
. k6 M4 W: U3 A {+ j1 T! a1 i' P, f
Run, cmd /K cd /D “%full_path%”
+ O4 ]) y" h/ f! Q2 I- t3 F d( b8 J }5 Z2 E8 C* W+ s) a4 J
else
' B0 w |2 T3 z5 N1 u {1 F' J5 K* |% ]: `
Run, cmd /K cd /D “C:\ ”3 ?* g2 K# `# n5 L! t3 k; V" a) ^
}
) Y/ h" K0 ], m7 A) g8 s% I }3 ^! i, j# o4 F. ^6 o
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
/ o: s/ i* n( K, k 这段小代码肯能有两个你需要修改的地方
2 e$ G1 h/ A/ M% w& ~! R$ O8 v% ] 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键8 T0 k. F! I: t% |( G
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
* L' n: E/ o# {, w |