此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。% I4 m$ K% W9 H/ l
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
# i) X6 u* k2 B5 N) e$ Z% h 方式一:4 L1 n- A0 A( m, h y/ f6 F
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,( F( X* U7 ~; F- f
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
1 W: Z: N0 c" _# }8 T HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
2 f& J. L( J4 Z# E1 x 方式二:
% O4 ~- R6 p& F4 ?& ? 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下: ~3 q N) h8 B) s4 ^' \
SetTitleMatchMode RegEx; [! ^- s/ O/ d& A5 m* p5 k/ }
return2 q8 }! F9 _ g$ I+ B
; Stuff to do when Windows Explorer is open
3 V) I$ i) q" O1 E$ x4 E4 Q ;
8 t6 E5 e0 K% m8 h7 x$ o #IfWinActive ahk_class ExploreWClass|CabinetWClass
+ ^' Y e3 o# @ ; open ‘cmd’ in the current directory6 t9 G) K* x+ c( |& v6 x# {3 v" M
;
1 R) r3 a6 n8 K7 k5 P #c::
1 X7 T* C w' ~# O0 x# |5 v OpenCmdInCurrent()
) c/ l6 ^! Q3 D9 d% ~0 a return3 h1 |" T4 V1 F! c# h8 S. a5 G# \( y
#IfWinActive- j7 o. v# n4 ]1 m Z4 [
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.9 E- b" L# c+ U; }7 h0 J
; Note: expecting to be run when the active window is Explorer." U% b: P) F. q/ D% h
;' v7 A# p, V$ N5 l* q$ l4 W
OpenCmdInCurrent()
1 o2 r/ N# q) Z0 U: E: r6 q! O {3 f( t! m" ?, A) |: A
; This is required to get the full path of the file from the address bar
" F- Z3 I& F% S, m* G8 Q2 j: e5 L WinGetText, full_path, A
$ k' F9 h2 P+ A- r/ ~6 i7 q ; Split on newline (`n)7 T9 q3 [3 l& ~9 R) S3 i
StringSplit, word_array, full_path, `n) P" h. ~# K: S" D# V, Z x9 g
; Take the first element from the array
: A$ r8 j+ Y3 G$ O3 I# G/ v full_path = %word_array1%
* d4 ]1 G+ ` N ; strip to bare address
# Y( ~0 [0 v# Q8 y' L/ v full_path := RegExReplace(full_path, “地址: “, “”). G6 m8 s7 |+ R3 \6 n8 }
; Just in case – remove all carriage returns (`r)
" m. `- }) E# g. D2 N6 L StringReplace, full_path, full_path, `r, , all
~. v( Z. E- V5 i7 D2 ` IfInString full_path, \
' |% Z s7 B% J2 S {
# z o! h. z! A N4 y: Y' R& h Run, cmd /K cd /D “%full_path%”
" F d+ O! V2 _+ p1 j: M, P4 h8 Q }
0 \+ p1 |' l1 D+ T. w! n9 A else- K( w! d; K/ n; W
{5 U. @ u0 f; H8 v( V
Run, cmd /K cd /D “C:\ ”
) Z* _$ y; q( b/ j3 g }2 T v6 h+ d' ^' S
}% h' Y! |% ^/ R+ B
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
4 D$ I) c, V. {/ e3 w P8 ]1 M 这段小代码肯能有两个你需要修改的地方) [6 v4 ` c: E9 ^) ~7 p9 F2 ~3 j
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
8 R% G8 `& B0 H 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
3 I, m p2 |, _: I! k& H# X4 o |