此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。0 O4 O( I+ C* G+ }" l
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。( s# R- `0 K* X6 f2 ~/ f
方式一:
' C& \1 k3 K* n 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,* R' _/ a1 m9 s6 r
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
$ D4 o+ x0 ~2 e( Q9 G HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
2 `5 N( {" o3 n9 G% w0 i 方式二:5 X! c; |$ O/ c/ E3 t" Y7 S$ S
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
! M$ T6 s4 H8 J# v5 Y; a2 C6 R SetTitleMatchMode RegEx
" ?# s/ Y& c# T1 ^ return3 L0 s- b' `8 q/ R& ^
; Stuff to do when Windows Explorer is open, L# k) D7 M. x5 A. r0 W2 {
;* ~# {9 p' r' q3 k; B* B
#IfWinActive ahk_class ExploreWClass|CabinetWClass0 J# P+ H- E6 Q6 q
; open ‘cmd’ in the current directory" o- e Q, n7 J! d; {* f* C, f
;
z0 G/ T! Z7 y3 W) S #c::
, C- P) n) q0 M+ U3 w4 J/ I OpenCmdInCurrent()0 X' [. f* q! G) p+ y" U7 p
return
0 I) Y( A3 K5 V3 A #IfWinActive
& `- @4 k* _0 U5 g ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
( g2 T4 w" n" X2 {; \5 {" s% D+ W ; Note: expecting to be run when the active window is Explorer.! e) t$ y7 J3 c/ U, g$ W- T8 \! m
;
# _2 u& T4 d" s/ X; M! R OpenCmdInCurrent()
% L5 x: y2 g$ J) U- J {
2 Y4 K- c8 C4 A9 p' T ; This is required to get the full path of the file from the address bar) P6 S' q$ F3 t% a- \& y7 s7 Q6 }
WinGetText, full_path, A
0 y, }* F/ A+ n- { ; Split on newline (`n)( I4 c2 G7 s" K& d- B4 z
StringSplit, word_array, full_path, `n. G3 Y* |$ S1 D
; Take the first element from the array
* L, l W1 D. ?4 A% f& B full_path = %word_array1%; A' l( {. \- ]3 W% ~7 w# s
; strip to bare address
( W/ _9 @) H: M full_path := RegExReplace(full_path, “地址: “, “”)- w; i0 N* p. U2 h
; Just in case – remove all carriage returns (`r)
; E. o1 S0 e4 W S! T4 G StringReplace, full_path, full_path, `r, , all
3 q, H J x: q/ s1 y) H+ w( Z IfInString full_path, \
1 D0 t$ B3 K8 L2 m4 P0 Z. L. P {
( n6 o2 A5 c) f5 O; }/ ? Run, cmd /K cd /D “%full_path%”
/ f7 |& F0 }3 k! M }, W: m. F9 W" U) g7 u! v: P
else3 L y% D( Y' [8 |9 b, o* ]7 H; p0 h
{8 F7 k9 b2 m) v5 Q {1 b
Run, cmd /K cd /D “C:\ ”
3 E: w6 a/ W& w. V3 ^; g- g }% v6 W; \7 F- X6 u
}
6 `$ b. W( n1 x. e 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。- w6 g( x6 m2 \: V
这段小代码肯能有两个你需要修改的地方( ?- @$ N$ L- f" ^
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
- @( N% Q, d' z) H' X l9 i; `- G" ` 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “% o* K) G. M$ Y. ^
|