此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
) ]% Q" a. J, K" [. l# P+ X 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
1 ~$ T U+ P% R9 D) x 方式一:( O6 \* H: t7 r, N
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,$ `' t" A: M4 t+ h$ X
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
8 J' s0 o. A6 t, q5 m HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
' o1 ~# }, n5 a* D 方式二:
/ b# e; d; l% u) C( O. x. ~* { 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:! ^. K5 r* e, [' G" q; o/ G
SetTitleMatchMode RegEx* k% q- h; w( R( U I# Y% {
return
/ \- c+ ]* T C& H% p ? ; Stuff to do when Windows Explorer is open
; P! T* V y9 y$ O ;
3 C e+ L& y- o$ F0 v* y #IfWinActive ahk_class ExploreWClass|CabinetWClass! G+ U- v2 W& x6 {5 L' t0 ~( G
; open ‘cmd’ in the current directory
1 n. }: L, n J+ k J1 v h6 d% T; v9 G ;! y: g* N0 J( o9 x- ~' ^: g8 _
#c::3 K1 V! B7 f$ m+ e1 h+ n8 J l" I
OpenCmdInCurrent()- i2 }8 C/ f& c0 H
return8 x5 @- k5 g4 D( M
#IfWinActive
# N1 B4 b4 {, O, l: S5 @4 t7 D ; Opens the command shell ‘cmd’ in the directory browsed in Explorer." ^; X, R! J$ C8 I
; Note: expecting to be run when the active window is Explorer.
6 m( Z- g3 \7 c7 L ;
% B% G {& }. c* T/ x* x$ [ OpenCmdInCurrent()
?. ]2 }: l4 J {
+ L. V, c( y2 A' W9 [& j ; This is required to get the full path of the file from the address bar5 W+ g# Q' I, U
WinGetText, full_path, A
0 ~& E- h& ]$ `" W$ [. D ; Split on newline (`n)
4 A8 g; }+ ^' ^% t; [ StringSplit, word_array, full_path, `n- _. v8 C1 Y0 N7 x8 G
; Take the first element from the array
/ r" J2 N# K- S* ~! L full_path = %word_array1%
3 A! R$ R1 K( i0 v ; strip to bare address
$ G, A j" G3 L1 L2 Y1 | full_path := RegExReplace(full_path, “地址: “, “”)
. ^- z( |' T# E4 N% q- j ; Just in case – remove all carriage returns (`r)+ g1 D0 p3 o2 E% G$ y. ]
StringReplace, full_path, full_path, `r, , all. i5 n! B/ j2 u& |* Z- \
IfInString full_path, \4 Q% q7 t3 H) x4 \
{# {6 ?* y/ _' _! u. \( i
Run, cmd /K cd /D “%full_path%”" C8 @& V( w1 ?$ D# [# b% A% u
}* }' R+ j! C1 H
else
$ [2 O% h3 g! C6 Q* A+ F& P {
T2 r5 \6 o! ?: [ Run, cmd /K cd /D “C:\ ”" d4 ~. i9 r) E+ G3 C
}" O/ q! K- `5 s$ P: `
}7 a' G8 K+ b. t# r; |
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
" }- I0 o! Z8 ?, |0 J3 I 这段小代码肯能有两个你需要修改的地方7 _# w3 g) c" a
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
' r& \: x( C) @# X3 k* r 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
% _, n2 p0 j/ L W" k: @ |