此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。( _0 X7 x9 _1 V N" C0 u
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。% A2 ~% M% u& h6 s
方式一:0 O5 {9 q( S3 b! @9 l% L4 P
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
6 k- G, [* |/ E; U 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
% C' V* o: X" _& b/ Y, q& K% I o( u HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
" ?( X3 n9 [0 e- J3 W7 W0 r. n 方式二:! p6 ]$ c$ z) S6 n& R1 o( `. C2 D
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:/ W w: ?( A! @& V
SetTitleMatchMode RegEx
4 Y; e5 i" q1 U: i% {& d4 {: c8 t return
) k# ^9 j' ^2 X5 J ; Stuff to do when Windows Explorer is open
7 ~7 N9 y0 }5 h* t# h. L7 I ;
- E; M8 s3 X8 t: V4 ` #IfWinActive ahk_class ExploreWClass|CabinetWClass
+ h( ]4 t1 `* g$ }2 P' D ; open ‘cmd’ in the current directory8 N! R @3 w3 Z+ b
;# H/ W0 l2 F& Z8 |( Q
#c::( n* X8 w- k/ r+ g" j
OpenCmdInCurrent()7 }9 `( M! B! l9 G$ Q2 u. X$ W: ]" N
return) E1 N$ y3 @: h( \2 ]- M1 l! I
#IfWinActive
h2 ^3 q& t: T1 a ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
4 F1 ]- N% E; X0 n, E) ? ; Note: expecting to be run when the active window is Explorer.' j# q6 F) N4 M* ?) i
;
2 C$ p9 c1 }8 _ OpenCmdInCurrent()
- X4 A2 [/ c1 E% N" {5 \8 }; u {1 B5 H7 s# W# `1 R0 s5 Q' S
; This is required to get the full path of the file from the address bar+ u( P$ }, Z: l4 p8 D* g+ r
WinGetText, full_path, A
s* r5 D7 I' j5 Z$ K ; Split on newline (`n)% x$ u* g$ u$ a" _
StringSplit, word_array, full_path, `n
$ V% J' G% ?0 C# N8 i$ V ; Take the first element from the array
6 Q) a7 i8 L8 ]% K0 p full_path = %word_array1%
7 G/ ^6 Z4 c8 L2 o ; strip to bare address0 |# _8 Q# X' U2 g
full_path := RegExReplace(full_path, “地址: “, “”). n3 |2 @6 N! d) Q) j( @1 l" b5 {
; Just in case – remove all carriage returns (`r)
0 A6 q/ h. g0 q; m% y StringReplace, full_path, full_path, `r, , all
# `4 d! u5 K |& a! s# x IfInString full_path, \
* k( j2 n2 P! r$ G {4 n9 X; q6 i' Q+ J9 T* b
Run, cmd /K cd /D “%full_path%”
s! H" H7 E- x) y! l, K7 ^& [ }3 ~+ a# ?" t, w* T, H4 a. q6 f2 m& O
else9 K3 r R `3 \0 ]
{
) I) s0 Z4 `7 v: F Run, cmd /K cd /D “C:\ ”6 D* j: [. G; F+ Z# U
}
3 _4 H$ J, c" Z* i. d' ~2 |( y }
, p; g5 ] E5 a 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。- V, I& n! Z. ]' B
这段小代码肯能有两个你需要修改的地方
0 i" O% t/ q, ]5 B 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
* h3 N! e& W2 V; e% n- G; ~ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
7 k' ?) g) P+ N6 n$ f+ e |