此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。' c+ Y, U$ Y& ^4 u4 H) |' P E6 h
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
0 @/ y t+ f; W7 X 方式一:6 C' S3 ]" s, Z& V6 {# I
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
- j5 g" ]. Z& V$ R" _! \7 x+ d7 z 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和- f' U! K1 a# \0 d5 n w4 y4 L9 s$ A
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。+ F( A" \2 q v9 E
方式二:
; D W8 N, J) Q9 j" P, A5 J 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
0 B& W4 Z6 m; r o+ m# h SetTitleMatchMode RegEx# F. V2 u% z7 c7 L7 [& y+ p0 t
return5 u4 D7 q3 B) |! F8 P
; Stuff to do when Windows Explorer is open0 d$ j9 P( R1 Z: N* n, m
;
0 A9 w2 a: Y* z #IfWinActive ahk_class ExploreWClass|CabinetWClass2 X. y$ y2 G; d5 R+ N
; open ‘cmd’ in the current directory0 y r1 D; T9 z k
;) }% n% C A$ W$ j+ g" ~' B; p
#c::
& v" [2 Y7 v8 [5 E# C- k OpenCmdInCurrent(). F6 M4 P1 E: a! B
return' U. W8 n$ H0 E
#IfWinActive
% E) k8 Z( c' |" c) Y" ]# p7 E ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
, }# ~5 r( n5 M; w! f, Q7 Q0 ? ; Note: expecting to be run when the active window is Explorer.
# p5 d5 Q% a" j2 M' k: W# s" g ;! Q# v3 H9 `0 Q
OpenCmdInCurrent()
$ a8 Z' V' i4 Y6 U) b {, ?) j* Q6 `0 P. E+ q8 N6 G
; This is required to get the full path of the file from the address bar
6 k7 i$ [* a" F9 m; j/ Z1 b WinGetText, full_path, A- H7 M/ W! o; q- \" G3 i
; Split on newline (`n)+ E2 \! z! [! {# ^" f* C6 ]- m
StringSplit, word_array, full_path, `n
8 w, z0 `% F9 ?+ F- G# R ; Take the first element from the array' h* m" L' v# D+ @, m% i
full_path = %word_array1%) T, }! d7 B4 `6 o
; strip to bare address
, X! r5 F8 ]5 h8 K( T, ^ full_path := RegExReplace(full_path, “地址: “, “”), ^- @8 n' y4 z, m2 F! [1 {
; Just in case – remove all carriage returns (`r)/ o5 z- U" |& x/ s3 c
StringReplace, full_path, full_path, `r, , all9 ^7 g3 M! U: G. g7 r
IfInString full_path, \
& z( d" Y& m) x3 h! C* S {
. t$ Z% k Y& S# K3 m0 o Run, cmd /K cd /D “%full_path%”
. U2 o" r l/ t }/ ^1 w5 A( F5 `7 ^; f! W8 \7 X
else
5 ~+ B2 p. B9 r3 L+ y: H {3 D2 t1 R5 ?+ |, |& h9 q/ l
Run, cmd /K cd /D “C:\ ”
# v; a# V; h+ Y _ }8 k9 y$ t) T ~6 m& H
}- M0 `$ E" P! j2 p) l* B# v
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
: o1 f8 ]+ e& g! s 这段小代码肯能有两个你需要修改的地方
7 Z: i4 ~3 l" r& ?4 n- H) V/ x 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键0 n) [, V3 y$ y) E* N" A4 ?; k
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
1 y1 T+ m6 e* a# k |