此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。( I- ?0 A4 ]4 w! h3 b
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
4 F$ P; g% j) F7 K$ n 方式一:
x# |1 j! K8 W( i 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
; a, q+ p% u4 n& R 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和; j2 h+ s+ U1 G! `- ^. `; S
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
) I* R0 V; c" o6 B; [+ t: X5 u 方式二:. j1 R8 G# a0 k. |
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:2 |' `0 Y! r& S1 Q$ i
SetTitleMatchMode RegEx
' K- Z+ z$ }0 V" ? return
3 M% ^% j; O( ~4 X5 Z% S/ D ; Stuff to do when Windows Explorer is open* z6 a5 S/ A9 j7 b- c* [3 M/ w# T8 t
;! ~) R: Y: K" _
#IfWinActive ahk_class ExploreWClass|CabinetWClass2 q! d5 F7 v7 ?, s
; open ‘cmd’ in the current directory
3 h9 F$ W9 V3 y6 ^" p- [ ;4 _" c' H7 n# }6 s: A- A
#c::+ C7 w5 z. a$ c; q- B
OpenCmdInCurrent()
5 R# w) j* e$ q- M! F+ l return( G5 ^7 P w0 y6 b: I% b2 B0 e
#IfWinActive
( X0 a5 u% R) }- b9 a ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
6 J' r, e) D( K J ; Note: expecting to be run when the active window is Explorer.
9 h! N: e) [6 [' S: l0 j- G) B ;
( X1 T) O& h! l" I ] OpenCmdInCurrent()' z2 c7 _' ~# K. k- }
{
- g/ m5 K9 n4 `7 M ; This is required to get the full path of the file from the address bar
2 K1 i# z8 b, ^; R WinGetText, full_path, A9 I* |. y9 g0 B9 |4 ]1 s4 Y- l9 P
; Split on newline (`n)
& L1 J2 g8 i3 h w2 ]) J4 W StringSplit, word_array, full_path, `n
4 O1 N9 k D' U% x- j ; Take the first element from the array3 i+ i+ t8 M e
full_path = %word_array1%
% s8 m; x3 H1 R9 I. ^ ; strip to bare address/ G% t- T2 K' B7 z9 V8 S
full_path := RegExReplace(full_path, “地址: “, “”)
/ n4 i: v7 F+ X! t0 r" G ; Just in case – remove all carriage returns (`r)2 f" [) S1 R" G. r% ]
StringReplace, full_path, full_path, `r, , all
, p, U. j& r3 v7 c3 K1 r4 c IfInString full_path, \
; s4 m- X8 B6 g/ s: t {+ M& A% i' H8 W0 K2 N& [2 N
Run, cmd /K cd /D “%full_path%”% |" g' B) V7 I& j* F& o: }2 |
}
, H- p" t1 k* I else# N4 m F* _! X" B2 Y8 T
{
1 @7 ]' `3 |1 J$ |: f% X Run, cmd /K cd /D “C:\ ”
/ a: P% m$ ^ Y* W0 b4 ?9 Q! r }
* `2 _! f2 u( m( u! m7 ]4 t }# ~7 P) ]- v" X8 n0 g
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
& F/ ?' P, E, v: K0 |2 v1 M- r 这段小代码肯能有两个你需要修改的地方
4 T9 @$ G8 O) {1 u% R9 ^9 a7 }/ } 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
3 f& x! G4 S; o u& {! L. D7 _ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “- r7 _6 ^+ u6 t5 T" M
|