此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。" M4 o+ H Z! [6 T5 X
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。! [3 P" P B5 J1 ~4 e
方式一:/ @7 t$ O! p2 x+ \- k$ c( _
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
4 ^& c1 {+ h5 e( _7 i* ~ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和9 T) C, j$ g8 ^8 k' X4 z8 x2 y
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
* A! g5 j8 y6 s5 [# _: n 方式二:
' m: A! _/ L$ g J( S- g) N; A 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:2 M9 u% \- W) |6 j
SetTitleMatchMode RegEx5 C$ M5 `1 A; m I; E
return
# f6 t( P H# b! V% D- ~ ; Stuff to do when Windows Explorer is open6 n9 G* i/ x( ]; r! j
;
H0 H3 z; ^* |$ @2 k: F #IfWinActive ahk_class ExploreWClass|CabinetWClass
6 n2 _7 N% ?2 @9 Q/ g# X" N; Y ; open ‘cmd’ in the current directory, r$ B% K1 x1 e( w/ a
;$ k) n/ O% m' F+ a* ?: r. d6 y
#c::
y: @5 q4 @, j' I1 y" M+ e7 J% C OpenCmdInCurrent()
2 X) J. ~3 n" E2 | return
$ E# I' V. b: q. i #IfWinActive
* q' W. ]. D" G2 t1 O ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
2 `; O$ }0 P$ ] ~- l6 ] ; Note: expecting to be run when the active window is Explorer.4 |4 u) c( V4 \# D
;
6 H: T( J* t7 h) R& i OpenCmdInCurrent()
/ g8 q/ |6 k# h2 f0 A {
" D+ j* C9 w: A4 K& J; \ ; This is required to get the full path of the file from the address bar
7 s3 w9 p4 R( K! B7 Y* w WinGetText, full_path, A
( L7 |+ C: U4 W' O6 s" {+ r) S ; Split on newline (`n)
: e# q) _4 v# Q1 T StringSplit, word_array, full_path, `n( O. Q* _9 m; r+ d
; Take the first element from the array
- q6 g4 n" \! U5 P# |6 d Z" d { full_path = %word_array1%& O: U4 r) T4 N8 e9 [; v# ]: q# U
; strip to bare address
: N2 d. D+ A1 ^ full_path := RegExReplace(full_path, “地址: “, “”)
9 E( U1 a+ |2 l4 Z; A3 d2 M9 a7 ]6 ?2 B ; Just in case – remove all carriage returns (`r)
- F" K8 \+ H' _# J( |' k$ _ StringReplace, full_path, full_path, `r, , all9 q I# d- H& s5 ~! }' A* Z
IfInString full_path, \
4 B5 c9 e% Z" T+ k5 O' E {
, q! M2 T* j5 l$ q+ m7 c9 v, Z& B Run, cmd /K cd /D “%full_path%”) U% j* k4 y: ], r, P
}
4 s1 r( S3 U, x else& {' I& F/ T/ H$ N
{, Y% X) @+ o5 X4 C1 R: L
Run, cmd /K cd /D “C:\ ”: K" i% a7 x9 o( T$ B& I
}8 v+ C- B) U" h" r
}6 E, @! _0 f/ Y$ t
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。! \) _! h% p1 _6 w* p
这段小代码肯能有两个你需要修改的地方: V2 l3 C/ J+ [5 w: y5 c
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
4 B) ]. ~4 v! P4 f: k9 _/ N/ S 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “; e- e, ~+ u: l- I* n4 Q
|