此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
: `- E# |% ^) O4 @$ O/ X 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。$ W: Z% U' X4 j+ C' c- Z4 B
方式一:+ W) a0 Q; _6 u* s* f# W5 g5 Z
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,: z% Q; l5 g' E
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
- d1 n6 y( ? X- c HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。" F3 d* _, J# o" U* M2 X3 N
方式二:, v* p% {' X, D/ w9 J2 B5 K Z
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:7 u: |3 j/ x' `% [
SetTitleMatchMode RegEx
8 `6 i. |: {4 f+ h return
9 } X3 b/ n3 Z# v ; Stuff to do when Windows Explorer is open
`# \! m/ c) g% s ;
* {4 w7 p: i6 V9 j/ z; Z #IfWinActive ahk_class ExploreWClass|CabinetWClass
+ r8 a! _9 |7 ~ z4 d ; open ‘cmd’ in the current directory$ e! \3 M' {9 {$ ]
;& X$ _. o5 h. u( S7 E" v0 V
#c::8 f& G0 |. k2 X. N! s k Q
OpenCmdInCurrent()( r1 `% g. W6 F6 Z3 S
return
" @0 c% g' i5 `+ n/ } #IfWinActive9 s7 F _. C/ Q: @5 n
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.- x% K/ J* Z" W5 I$ L
; Note: expecting to be run when the active window is Explorer.
- u! X8 |. R0 [7 a ;
' t ]# P5 g7 _8 h$ _ OpenCmdInCurrent()
" \6 y/ {1 q+ J5 b! z1 N {
0 B5 h+ v6 q/ n! g3 e: t7 l" a ; This is required to get the full path of the file from the address bar
: K& v! u6 w8 _) C# } WinGetText, full_path, A
" @+ B1 H. _: Y' R1 N ; Split on newline (`n)- M5 Z" e- g. L9 o
StringSplit, word_array, full_path, `n
2 D0 N% ~/ ^ v5 n5 ]; t( s; I ; Take the first element from the array
- q' s, H% Q( w* P& n+ I/ e5 h full_path = %word_array1%) g0 `' g2 n" h' t$ e2 [8 m8 E+ I
; strip to bare address
7 p& B3 @1 r4 R# ]2 F6 {. C: B/ `8 U5 } full_path := RegExReplace(full_path, “地址: “, “”)5 d! `3 e& L" M, Y/ J
; Just in case – remove all carriage returns (`r)1 X$ Y0 D7 m& I- H4 U
StringReplace, full_path, full_path, `r, , all
# H$ K, t d1 @, _ IfInString full_path, \
& u E; _6 ]+ g+ c {
6 d9 n. \: N3 N2 Y* F& P Run, cmd /K cd /D “%full_path%”
4 m1 H* X: | { y) X }1 B( R3 m( ^! R3 E; z1 D
else5 n, U/ f, F: e0 v: z+ a& J* J9 Z* m
{8 ]# L+ a$ {5 a+ T* y4 [
Run, cmd /K cd /D “C:\ ”
$ X6 L# |% z" q) J }6 j) W ]# E& q. W( d. e
}4 y: L% F6 l# x/ l: Q$ ^# I4 T
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。 ?" q" Z. _& H6 Q& }9 z" Y
这段小代码肯能有两个你需要修改的地方
( [! L) I F7 O1 i% O0 d, W 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键; B7 [; H( ~7 D& n7 N+ @" q+ O
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
7 `, J* f/ G9 G+ U4 }6 z |