此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
5 R& J- e! C1 O+ G; c+ E) K 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。2 r: `6 l+ d6 z9 @ Y6 V
方式一:
& }+ Y; S, A Y( m( h/ l) i! Y 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
' Z: ]: L" D. B% u 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
3 A/ b. }# o6 p$ r, v* L, g HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。5 A+ B8 t3 u9 @4 d
方式二:0 t! W [4 q, R/ h. |4 ?9 ^% I
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:3 X' z; V6 B6 }8 H8 o
SetTitleMatchMode RegEx, g' y8 Y9 g7 k& d
return
2 h* ?9 m: G8 y- C( Q( ~ ; Stuff to do when Windows Explorer is open, m2 F9 t7 `8 ?8 _
;$ g2 H0 w5 {0 {, {, u _5 n
#IfWinActive ahk_class ExploreWClass|CabinetWClass' V. v, J. H) @4 I& N# q3 `% z
; open ‘cmd’ in the current directory9 m' W, Z* E: }, w5 o
;
# j% m0 D, y. u* ~. P #c::" q1 g$ G5 p f- B4 k: E% B
OpenCmdInCurrent()0 E! d4 r1 Y$ n* d1 `& `4 Z6 e/ j
return
% H9 a( [/ Y% f& T# y #IfWinActive
$ o$ a# `( Q) s ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
% Y* `4 C v! i8 ] ; Note: expecting to be run when the active window is Explorer.
7 w. I6 P* L- G" p! S4 ~ ;
! \8 D2 t4 o/ `+ O, G OpenCmdInCurrent()
, i# p; H- f2 _+ `+ H8 f {
7 Z( b( b, v( a: u" h1 N% L ; This is required to get the full path of the file from the address bar
4 G+ k0 x; Y2 w4 l. z& K; M WinGetText, full_path, A% l) F4 ]2 v' A6 x: r% q! r8 [# Q6 c5 _- d
; Split on newline (`n)+ C6 v! k' ?6 u
StringSplit, word_array, full_path, `n
" k$ {& _2 ^5 Q4 w ; Take the first element from the array5 q* @: k: M) M# }2 P
full_path = %word_array1%
4 x$ Y$ S3 L! E# I6 \( J ; strip to bare address
: K% c1 P4 Y! w2 F full_path := RegExReplace(full_path, “地址: “, “”)
% _% P- q# l( C ; Just in case – remove all carriage returns (`r)
6 i- \' |, M9 y' V StringReplace, full_path, full_path, `r, , all, s. q6 l8 D7 c5 l- T7 F
IfInString full_path, \
( \! ]- L! q- b" ]4 o5 w: j3 s# \ {
, T3 Z( R+ D L. [# ` Run, cmd /K cd /D “%full_path%”
- Z9 T# S( g+ Z3 A4 {% Q }
$ l# ~! v9 Y9 K6 Z7 I) u+ w else5 a) e& J, H5 O# X8 ]7 b
{
1 F* G: z. l+ a6 n Run, cmd /K cd /D “C:\ ”
% V8 `" C; W0 t5 @0 o# c Z }
* I ]% k, m7 C! X( @5 L }2 U/ m8 d8 Z2 t7 h1 `" T
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
& |3 Z6 v' h! D9 B 这段小代码肯能有两个你需要修改的地方
' W$ M W& j, [+ u 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
8 o8 `# g) H7 c( L0 w 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
6 x; ?$ e. a/ f' [" B' j |