此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
+ u5 C0 V. r0 U. }$ ?: T) s% A- i 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
0 Z; }9 H8 s% B4 n1 ` 方式一:
. h) [3 x1 ?4 e 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
0 ]+ I8 E- U7 F' i: y# i 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和/ P" Z# n) e. L
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
3 c6 P* a. Z$ y" m$ j# n3 N 方式二:( k# k/ ^; b, X5 C1 S9 G i o, n
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:1 i7 K0 ?3 K4 C6 G4 ?5 _% d
SetTitleMatchMode RegEx
, u9 I% c) H4 H ~: H) L return( I9 H: i4 t& Z2 K3 M$ j$ W; b
; Stuff to do when Windows Explorer is open
* V) i9 u( @4 E( s/ U ;7 @+ f9 V( g0 D v! J
#IfWinActive ahk_class ExploreWClass|CabinetWClass
' b, C: H0 i0 B: H) X ; open ‘cmd’ in the current directory
* {! N* O! f% Q } ;
0 m. ?& E8 A9 T2 ^* r; ] #c::( B1 `0 ~1 U5 [* z# H! I( o+ w
OpenCmdInCurrent()
; [' q# q/ t' X; j* J return
# f: N! g5 p4 E, v #IfWinActive% L# D" T* e* |9 U7 F
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.7 b% Q( d+ |2 s- f
; Note: expecting to be run when the active window is Explorer.
7 p5 ]$ m, \: u, V8 q ;
4 }& X7 ?8 X3 E0 r7 ^2 p2 Q3 F OpenCmdInCurrent()
2 ~( t6 H1 g$ ?0 X. v( j {# c# W4 |% |% {
; This is required to get the full path of the file from the address bar
5 G' I5 G! p* ]! K WinGetText, full_path, A; ~( h: h9 `" X* d% r+ b
; Split on newline (`n)
/ v2 `" w4 ]( |; r. \ StringSplit, word_array, full_path, `n
8 R/ V; s8 V; L/ r' p6 O ; Take the first element from the array. V$ [: t6 x% T) R. t$ a3 W
full_path = %word_array1%
& @# P1 K8 G3 i. t ~0 q+ ~ ; strip to bare address8 }' x7 [7 u0 i0 ]
full_path := RegExReplace(full_path, “地址: “, “”)
8 o9 n# E. i$ I W! B ; Just in case – remove all carriage returns (`r). S2 ]; h2 ]( ~4 s9 Y. u
StringReplace, full_path, full_path, `r, , all
5 N! t3 W: T' L/ b: E IfInString full_path, \
, M$ b W' N5 r. c" e7 m! q+ u {
, b' A2 Z9 s7 G X Run, cmd /K cd /D “%full_path%”7 `8 M- M- P+ h
}2 {$ n0 O! v2 h3 k: c4 B
else
9 R2 j# N" C* s8 r {+ |, l# S1 k( G* b
Run, cmd /K cd /D “C:\ ”1 A8 {, y/ s4 U& A
}
* {; }/ N+ n# R9 P. @. W }
- F1 U6 v" X0 F+ N1 U 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。5 C1 S3 K* w' @7 i9 O9 m. w
这段小代码肯能有两个你需要修改的地方% @! {0 m0 J0 ?' z9 W7 Y
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键' N( N: }# e5 E. C4 M9 z$ ~1 Y" O
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
- |4 e ?, X0 C |