此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
+ v( M3 y/ {* H! ^3 n0 k0 _( e" W" V 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
9 O) k5 ~" y* E6 W( {' Q3 D1 q4 n% u 方式一:
4 D- n' ` L! i( R 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,- I, ]% ^' \1 R
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
0 q+ n6 f5 H$ |* v( j5 m HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。4 X( O0 {, K: j, \6 ^* C( Y/ z, D
方式二: H5 H X9 X# F
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
7 c8 a9 U- n5 d# f SetTitleMatchMode RegEx8 I; s E H& G8 m' ?1 t
return1 F7 y7 D- C) ]7 u
; Stuff to do when Windows Explorer is open
6 W: y% U0 W+ Z# U% L* A: z ;& x: ?+ v1 j& W: C
#IfWinActive ahk_class ExploreWClass|CabinetWClass
* N0 x+ [, T3 A# a" x3 {2 h ; open ‘cmd’ in the current directory
+ M+ ?0 E( H7 c$ o' ?7 [) o( x! I, h ;
, R5 v# H# t! [ #c::
/ c5 C1 c; ]2 g1 J5 R# y OpenCmdInCurrent()
: B0 u/ ~' R0 {5 Z: s) W return
( _( D8 T# q/ o; \: S* M5 R #IfWinActive1 Y2 q! A S8 g: R" o+ R7 B5 W
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
9 L9 z/ t9 ?* Q ; Note: expecting to be run when the active window is Explorer.8 R' o$ F& `3 x! d
;9 g6 h6 V" b2 J- k+ R9 Y1 E
OpenCmdInCurrent()
& ^1 }6 J( x |/ }) j3 Z1 ~ {
* u6 c9 l# B/ {6 F ; This is required to get the full path of the file from the address bar
# |: ^/ L) h2 K6 T+ q& {8 | WinGetText, full_path, A
/ P1 m9 v/ m6 o1 l0 ~. O! }9 n ; Split on newline (`n)
$ X: }* K8 G9 `! }" M( [) a StringSplit, word_array, full_path, `n
, J& {/ }8 _! d3 t9 u2 ^ ; Take the first element from the array5 v# Q% \9 l W2 |/ R) ?3 v7 l
full_path = %word_array1%- A% e5 y; d% z5 {, s
; strip to bare address
% X4 z$ }' u7 c# ^ full_path := RegExReplace(full_path, “地址: “, “”)
4 P8 L+ g( J8 z9 Q( a ; Just in case – remove all carriage returns (`r)
& [, n0 l/ `6 l9 @/ M8 A StringReplace, full_path, full_path, `r, , all
9 j! e& {" U2 o1 S7 } ?6 ?( P IfInString full_path, \
# b3 a$ ~5 H8 m$ X% \7 g {
! I* P+ {# _& V. N/ _/ H5 k) Y Run, cmd /K cd /D “%full_path%”) z6 l& h5 s2 ^- V. o; o+ @
}* _& ]3 R$ Z5 a- h f
else
' Q! N1 o- v& W# R {
$ A2 E5 ?% w: M z* X Run, cmd /K cd /D “C:\ ”2 j" G8 g1 z5 `+ D, V
}
' Y- a' W/ G8 @! w) W }& g' q8 T1 B5 R7 p) M
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
- p& h9 Y7 j" C! P: Y6 g9 K 这段小代码肯能有两个你需要修改的地方) S2 d' ~' L. p! ]2 N
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键3 E# @: e/ X1 h
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “. t) _: d m5 k7 m
|