此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
8 o6 I+ F3 h! u# P 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
2 [' ~: o: k5 M, n2 N! n( ?1 x 方式一:
9 x, H; p7 ?/ F K& z6 b& a5 a 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,5 b. f w- q0 A$ ?1 f! W
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和, \) B; n) p- D: H) C
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。) G0 c' L N! p& E' `" }
方式二: n" O' ~/ X5 V! y8 j! t
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:/ Y4 s1 l" D6 u4 R5 t$ C
SetTitleMatchMode RegEx: q) n+ J8 G2 f& o9 y" M; @
return
/ t) j" f. e+ G( O ; Stuff to do when Windows Explorer is open4 _# O7 S9 n* l6 \: B8 a A
;, C7 @9 N* T& D
#IfWinActive ahk_class ExploreWClass|CabinetWClass
) ~4 \6 ], }% ] ; open ‘cmd’ in the current directory
* n* c" K' \ O, f, T2 k4 s$ e" T ;6 M1 P' t( L8 Y) i: G m8 H
#c::& V0 ]! C# \4 F ?* W! f. r( I4 E) b) F
OpenCmdInCurrent()' D. |: j! ^$ V7 ^$ e
return
1 {% E6 N6 `! @* ~$ j #IfWinActive! ~6 }7 x% x9 R1 T1 x
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
- a8 D; ~( q* i2 _+ r ; Note: expecting to be run when the active window is Explorer.$ N% \/ O3 }4 K
;9 C; ]7 r' D* o) N7 p( P/ w8 m& f
OpenCmdInCurrent()6 O* {- K- m0 D4 r" Z
{9 X; Q/ D. c+ H9 q* C; p
; This is required to get the full path of the file from the address bar7 T3 `5 |* B7 M* _4 g. @
WinGetText, full_path, A
0 B- W; N6 W; c9 H# @7 ?# U ; Split on newline (`n)* @' O( V9 c4 M t0 H
StringSplit, word_array, full_path, `n0 R- E% |- w8 g& _, Y
; Take the first element from the array
0 V6 L) ~3 W B) q1 t- B full_path = %word_array1%* }0 T4 ~0 a1 d: }, y( `# J
; strip to bare address
2 A/ ^6 }- ?% N" \, Y+ S full_path := RegExReplace(full_path, “地址: “, “”)! Z7 U9 \+ }$ M- ~# i O
; Just in case – remove all carriage returns (`r); k4 g: t0 ?" J o3 ~
StringReplace, full_path, full_path, `r, , all
7 E* h9 W% c6 e% K7 d IfInString full_path, \' D1 W: e2 ]* F/ \; | i2 [& Y W
{
9 Z* s/ G( Z9 f; u5 A; _% C Run, cmd /K cd /D “%full_path%”
; h' _, P/ p1 [" s1 S- j' _ }
$ h( L/ W* D9 d- \. m4 V else8 Q8 h- [) s1 X# r- C4 q$ a- t) b- Q2 F
{- w" E/ N! @, Y
Run, cmd /K cd /D “C:\ ”9 t u" X% y9 E9 `9 i/ f
}
1 x9 z7 {0 H% g5 D: U+ L }0 m) G1 l, a) J7 S
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。1 ]" R2 p" Q& U9 H
这段小代码肯能有两个你需要修改的地方
4 T6 q, V: |8 F" N 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键$ W* |& v0 s% W. q. r9 W
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “8 \9 `, m. N: ?9 l) H" r
|