此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
; ^8 O& @! t& t/ k/ Q) z8 B$ X 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
, S* B+ e) K2 a, d9 D! Z( z' d 方式一:
0 p" m6 E q' Y. I+ C 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,9 S! c. n) s% _% ^( n
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
# b+ ?+ c# \4 _" y/ B HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
: |8 J! ~. Z' D1 L/ |. w, S 方式二:
( a- b% F: x/ b 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:3 U8 j8 I B# A; w0 c0 b9 |
SetTitleMatchMode RegEx
5 H# v) q4 w$ d7 @7 S2 n% B8 D return9 F2 T7 Z1 _9 \8 h! P: ~2 j
; Stuff to do when Windows Explorer is open
$ P6 w- C3 q9 A ;" X* E) G& M" p, e) Q
#IfWinActive ahk_class ExploreWClass|CabinetWClass" {" ?+ B7 q1 u3 B2 Q( }
; open ‘cmd’ in the current directory% s4 O. f) P3 u! o3 z; [: e
;8 n; d# G# s6 c2 @: P6 l
#c::
W$ N+ ^3 r1 A$ g* G- C: e" y OpenCmdInCurrent() `. h) @; e) f
return) y& u1 d& z6 U4 ?2 u* j
#IfWinActive
" F" h: E0 ?# K) |- o8 L' ` ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
3 X/ _- A7 t3 `: Q( i6 Z ; Note: expecting to be run when the active window is Explorer.5 ^5 T4 ^1 ^7 e8 ]0 E1 s2 x0 S9 Z
;
0 p" g3 j$ [5 [/ e8 ~: Y) _$ K1 m OpenCmdInCurrent()
' V8 h) }5 T- J3 S% a& u {" x" s( r2 a% m2 a
; This is required to get the full path of the file from the address bar- M) V. e3 k9 M2 |. C8 Z+ {, ?4 S3 s
WinGetText, full_path, A6 ]6 t% U+ K9 ~# j2 J
; Split on newline (`n)) O/ ^; [1 V2 \9 i; u1 w: x
StringSplit, word_array, full_path, `n
c7 b, Q; _! u- j" m ; Take the first element from the array
4 Q9 z3 v5 n2 ]6 B7 I/ @ full_path = %word_array1%
* P% z; Y7 x2 h2 L0 |* ] ; strip to bare address' k" D6 \ m* s3 {
full_path := RegExReplace(full_path, “地址: “, “”) c8 |7 e* n2 j* m1 R) ~
; Just in case – remove all carriage returns (`r): @; {) Y4 Z# _- E' i
StringReplace, full_path, full_path, `r, , all$ `4 ]/ ]- t: i
IfInString full_path, \
* j1 ?" }) T7 w8 ]1 F {
4 Q6 C+ |) z9 J" ~# \4 B Run, cmd /K cd /D “%full_path%”
' R0 I1 |* E+ k8 ] }
4 r3 Q8 p5 U0 t/ n/ g+ D3 I else
3 s2 y/ m% R9 |# s( g {
& d. J! g/ a* T* c# N! h# w Run, cmd /K cd /D “C:\ ”
! ]7 y+ s2 M* I! g7 J( N }! D4 p7 W$ p( A( X; V5 q' t. r( o$ \' `) i& E
}+ Z7 F! }& N" m/ r) `0 N; T- J# I
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。! c' X, Q6 h# r$ V4 \- Q
这段小代码肯能有两个你需要修改的地方
: Z0 k. z# }6 L 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
9 _" Q2 `& W5 ~3 \2 C% T, @ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “, i& @7 ?. O: \
|