此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
$ \6 J9 j$ l7 ]) ^/ Y. C9 q 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
# |% p; [! o# W/ | 方式一:
# n* c, O4 _ T4 R j3 | 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
- v2 {8 j1 q& U 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和# K: {" D5 X1 [' g0 }& e Q
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。1 E0 j+ t- b2 m5 Q
方式二:0 A# l, x# g( f; B, Y5 r" L! a
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:* C8 X8 b6 _ N' a
SetTitleMatchMode RegEx1 @$ l: k* t6 s- H( B; \
return
+ L: P# n& N3 | ; Stuff to do when Windows Explorer is open
4 H4 p$ D; \+ p; S- c$ N ;# J# S3 x$ k8 S) A: R7 y' I
#IfWinActive ahk_class ExploreWClass|CabinetWClass& O) U0 ^/ Z C+ {
; open ‘cmd’ in the current directory) }, U; a! @! p1 P. c' v/ @
;9 W' @9 d8 b! l/ N
#c::
4 W% P- J# r2 R: J, N! J2 W" F% D OpenCmdInCurrent()
6 x5 @' T% c# K9 B return
7 W. Z6 @9 Y. x6 S$ f #IfWinActive
; s+ p' _. ~# U5 v: F+ X1 d ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.$ i8 y* O* t: b+ w# e: |7 N
; Note: expecting to be run when the active window is Explorer.
# P" y* T0 V8 T! ? ;
W- n6 @4 y- Q- d1 b OpenCmdInCurrent()
7 M* ]' c6 T0 [; k( X {
0 ?* z5 }: u2 k% ~. P ; This is required to get the full path of the file from the address bar
& i0 s4 d2 g7 B- l* G `3 _0 C WinGetText, full_path, A: L- ^8 I( m# ~3 X x% Z/ n
; Split on newline (`n)
6 ]8 X# z4 U) o1 d8 s& b6 M StringSplit, word_array, full_path, `n2 t1 ~4 `" K1 y# |
; Take the first element from the array, B' S# n7 L; K( [( d
full_path = %word_array1%1 v0 j+ y9 r* s0 e6 h! o5 ]
; strip to bare address+ w2 S' a; o: c0 ]- S
full_path := RegExReplace(full_path, “地址: “, “”)
* \ X& a$ {" s6 h s3 b ; Just in case – remove all carriage returns (`r)
# g& i t" S* W StringReplace, full_path, full_path, `r, , all
; d* r' a( F7 C8 h1 j5 I IfInString full_path, \
; Z; q! w6 Z( i2 f( l {
; [ s8 ]9 J$ o! ~) d8 z0 x( o7 ~ Run, cmd /K cd /D “%full_path%”
% |+ ~% G( A* m1 ~' r }
2 d: e. h# }# E else
c/ }% q% \; Q O! f6 w8 Z {
8 L! z+ D6 ?# @- h# J5 }& f/ c5 f Run, cmd /K cd /D “C:\ ”7 F* U, u" W8 D* P- F
}
9 H+ K( h+ D$ A3 \: J; C }
Q- U' G/ N: _7 G4 R6 i 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
3 J# C. E8 |* E4 Q; F$ b 这段小代码肯能有两个你需要修改的地方
/ F9 l+ F( Y I5 r* v6 ] 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键0 `0 m4 u' Y! ^. k* h' P
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “* y3 J( d& X: }% V K
|