此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
' a* G5 R1 F3 d$ `. o 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。/ b9 L. i, N* |$ ?
方式一:7 E1 [2 V4 m! C8 E* f
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,9 X- a: f$ D& W$ i, ]. h- h: D
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和; i& }2 b! a$ ~5 E7 y* I) {' E
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。# `5 d& x9 T, u2 V
方式二:
/ \' `6 v* E/ v4 x6 V 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
. ?% S$ I5 h9 f SetTitleMatchMode RegEx8 x$ D0 y; K$ @1 H9 o
return0 k" t! `" K" F* o
; Stuff to do when Windows Explorer is open
3 x3 x! X6 s) l9 Q' l& _) g' Z3 O ;
9 k* u8 S: H% R* G2 d8 J #IfWinActive ahk_class ExploreWClass|CabinetWClass0 w7 z1 b. D% K: a
; open ‘cmd’ in the current directory
6 i# m+ ]9 b3 c7 B: m& B& i ;: A( g) e6 ^: N$ e" D ^9 F
#c::
6 [# G9 d. c. S OpenCmdInCurrent()2 _1 K/ y7 O9 P5 }( x+ Y7 n
return* u" ]7 d4 ]1 L7 [5 F
#IfWinActive
`9 I- N) V7 ]) ^7 d ; Opens the command shell ‘cmd’ in the directory browsed in Explorer. r5 c8 L7 f7 n$ n) ?+ s
; Note: expecting to be run when the active window is Explorer.* E& A/ l1 W! F. D' v5 E6 ]
;
0 a* L. k- N+ j' w. P( n OpenCmdInCurrent()) e* q+ v5 Z/ N! A* V! ]0 A
{
; w% X8 S) s1 B ; This is required to get the full path of the file from the address bar
+ B9 A0 v7 t- v1 l V: E3 w WinGetText, full_path, A
% X" [- U4 M, l" b ; Split on newline (`n)" J; I1 u( |" o1 j1 x
StringSplit, word_array, full_path, `n
, K0 I; y) K# W' k9 S2 f ; Take the first element from the array: U D: A' ]4 p
full_path = %word_array1%
9 Y% W& R) c( D/ x2 M1 b( S ; strip to bare address
6 b2 k' u. p/ F) ^" y full_path := RegExReplace(full_path, “地址: “, “”)
$ ~$ O: r8 l, y) k ; Just in case – remove all carriage returns (`r)
) o" [. e- G) O& }/ T, F& k StringReplace, full_path, full_path, `r, , all* s; F; b/ i* |7 N, V* ~ U! J
IfInString full_path, \: {) F+ b0 e4 ^1 M
{
" W. C% e& Q) ~8 ?3 q Run, cmd /K cd /D “%full_path%”. _6 F6 |/ M- z9 ]1 X& E& e
}
/ d, Q5 U" a* U- D+ E/ G else/ y8 {7 Q, F- h% Q7 j$ ^" p
{
8 N/ g; F( C3 H4 u5 d1 W Run, cmd /K cd /D “C:\ ”+ ?, \+ O6 x" c# p+ P/ E
}* Q7 C" ^2 R6 G7 j# F
}
& Y w9 `6 d' O& p& {" d 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
4 M' W$ `& m& E6 p3 v3 O 这段小代码肯能有两个你需要修改的地方
9 F6 o; t9 [! C& y/ P9 Z* u/ H 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键$ D3 h/ @2 q5 P1 f( p E+ J
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
9 n! G0 X! t8 n# z% |- C8 _& A) \ |