此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。' U, _/ V6 H) m2 Q& i+ P5 W5 ]# h
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。/ b/ F- o `! \7 z% b O
方式一:1 a8 z7 |' t" s8 W9 n- g
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
1 a& U& y( O' y( F* H 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和5 W U& R$ @" Z7 H4 F9 t( P
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。2 `3 g5 F, j$ T1 x n
方式二: o( V# V9 E3 L3 z7 a9 G
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:! ~7 ]4 X& e! G3 i; C D
SetTitleMatchMode RegEx
- _9 W0 b! F3 s. N return
+ Y" y$ l! J% W8 Q- Q5 @ ; Stuff to do when Windows Explorer is open F- |7 o6 D: E) X4 e" B6 s0 p
;2 s7 ^/ Q, B4 ^! p
#IfWinActive ahk_class ExploreWClass|CabinetWClass0 r9 p+ `1 N0 [
; open ‘cmd’ in the current directory
8 }0 c& e& I: X+ e$ z ;/ n! S/ \% }2 }4 ?
#c::
) E& y' h# n: _5 Q1 u0 @ OpenCmdInCurrent()2 m5 b$ L7 ~; r; j+ R% c! ?* y
return/ K( @# t3 w' [! a, S
#IfWinActive3 G1 h' N6 t" o% t) K5 E# X
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.# T, {% G3 f8 ^
; Note: expecting to be run when the active window is Explorer., T$ ^ H0 n- v& V
;
. k% E5 F% R) Z o1 {$ Z p OpenCmdInCurrent()& p6 F9 m+ n, B0 c$ o
{6 P, P. B! V: r. q9 ^1 }
; This is required to get the full path of the file from the address bar; P p8 u3 K1 j, `, D' k
WinGetText, full_path, A
# B- s8 E; K$ B. f ; Split on newline (`n)
# W% _8 [, f7 G0 |. w StringSplit, word_array, full_path, `n; C' B! A3 t2 e u, S5 ?
; Take the first element from the array
' G6 I0 Z* H# |# \: a- p* \2 K% p) o full_path = %word_array1%
, V3 F2 Y ?( W' h( v) z ; strip to bare address
7 Q# f, M/ g' P5 S& c4 z full_path := RegExReplace(full_path, “地址: “, “”)
; T7 i6 A9 v3 u( n7 J0 J$ p ; Just in case – remove all carriage returns (`r)
- ~8 r# l+ ?8 K StringReplace, full_path, full_path, `r, , all) ?1 w$ P" M0 A
IfInString full_path, \+ ~- }% N/ J0 |1 h
{7 d4 q0 u R5 h/ ?$ _
Run, cmd /K cd /D “%full_path%”0 o2 @1 b7 p% V/ n
}
4 \% B+ p. g+ \+ T6 E C( R else
" q; g$ @' h# s$ A: J {- l1 \! j& v2 K" Y0 {
Run, cmd /K cd /D “C:\ ”, n, `% M Z* t% B& y. N" e8 h
}
8 e' a8 f0 E4 k3 ^ b }: L! `' Q5 ^4 O8 ^! w% ^
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
* g# p) p, |% L% Y 这段小代码肯能有两个你需要修改的地方" @3 {5 \ C7 y/ a) Y9 a* H" \
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键! L$ w2 j9 u3 |2 V: U: W' A
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
7 W d2 F+ J% |, l |