此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。% c9 ~, c4 Z/ o, S& Z" `* `( b
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。- L1 i& l! W5 }) L
方式一:7 N, X8 g9 @9 T$ \ n; U' h6 V
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
) i% T' ]- N" k. ?1 V0 h 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和, W3 d( L! Y9 R6 a5 s' d* U
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
1 @/ l+ f5 H. [8 L- z- c 方式二:
: D9 b a6 X& _. \ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:2 P$ z2 r; _3 g
SetTitleMatchMode RegEx
! T& V' ]3 j: t1 b8 u( F& t return
- n' P" I0 i, ]% x ; Stuff to do when Windows Explorer is open
" p- M! }9 @3 Y+ F; m1 } ;6 R: q; H2 T6 d. [7 B+ c
#IfWinActive ahk_class ExploreWClass|CabinetWClass
' o7 k: y3 u d( w ; open ‘cmd’ in the current directory, u( F- K( h' Z k) V5 ~) s& z
;. J2 F" _) S8 z
#c::" c/ I4 ^2 z' Q8 N; G, T
OpenCmdInCurrent()
5 p, ^2 J- J7 I) g( o return6 Y6 ]4 y3 p9 b5 Z' O8 K1 a4 Y
#IfWinActive! [8 V+ m* k$ ~, A* h) m( u
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.& e2 S. }) ~2 K. D
; Note: expecting to be run when the active window is Explorer.
* T$ D# A0 o' K4 X ;
7 [) C5 k$ f( q: W- \ OpenCmdInCurrent()
1 T$ ~; m/ b- A {
& f. x2 }9 P0 w, N ; This is required to get the full path of the file from the address bar {) E: _7 |2 v( W) k" J6 Q, m. G# \
WinGetText, full_path, A" z4 q- y }$ h/ D( W8 U
; Split on newline (`n)6 \( `! `0 S8 R; m i2 Y
StringSplit, word_array, full_path, `n4 S( `# L/ J3 I8 Y, l
; Take the first element from the array
& K" B3 e5 b+ V" G full_path = %word_array1%
3 W, @# {8 c) }2 C/ T2 [+ w ; strip to bare address
. |) w! i R4 A" N4 M0 i full_path := RegExReplace(full_path, “地址: “, “”), F7 z+ M. E& e, M/ ]5 F
; Just in case – remove all carriage returns (`r)
0 O1 S4 G8 C( D( A StringReplace, full_path, full_path, `r, , all. l6 \ O( d& Z7 f
IfInString full_path, \
- S1 H" [& B5 y- s- m {
) o$ _0 P" {4 ~ Run, cmd /K cd /D “%full_path%”
" n F: D$ U& {, ` }7 }6 q& c7 n& Q% |
else
( U# c' F F4 L1 D1 r, L {
2 F& Q8 q4 m6 J) t) m! v8 }1 U Run, cmd /K cd /D “C:\ ”+ X0 B* a1 U& r r( H
}) R* |3 f1 P# n- k
}( `1 h* ~+ n* e! K( r1 E e* D+ n
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。5 H* y% b8 H t( V& }) z; J6 H2 b
这段小代码肯能有两个你需要修改的地方
; Q0 k& H3 c' `) D- v% r' T& v0 n 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
5 f( y, n) e) o% ]$ _ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “! h: S0 M! H; P- G/ v
|