此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
2 t: S3 O" Z9 r8 g 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
# V3 j" r8 w$ j9 V7 d 方式一:
3 O9 K) [2 Y+ @3 C) z L9 ] 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
7 g: l# Z: P7 w2 K- T9 N& Z5 T 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
4 j8 ?8 M: p i1 L+ L HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
0 q3 H" }+ _9 O* e8 U& Y3 i 方式二:8 ? _2 u$ @4 b2 S
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
3 H2 {" z. ^6 `# v6 O SetTitleMatchMode RegEx) l7 w" U% v; ]
return* v0 q; ^# e0 c' K2 `" M, M
; Stuff to do when Windows Explorer is open
* |' @( @8 W7 W0 b& m' t ;" C0 v" B" L4 m" `; W
#IfWinActive ahk_class ExploreWClass|CabinetWClass
3 ^, o/ b$ h2 ^ ; open ‘cmd’ in the current directory
: x1 b0 W# W! L) U: @ ;: q- x; T1 f- F: y2 p
#c::
$ \! S& S5 u7 b# f OpenCmdInCurrent()
+ {* B( ]: D9 T return
1 u8 d3 Q% C. r! m #IfWinActive
# P8 W' O+ l' n$ a) p1 e* U ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
2 }; X0 U8 ^. c' Y; T ; Note: expecting to be run when the active window is Explorer.
z) c$ s. b3 N2 [0 U' c ;* f' g& E/ F% y3 i, J$ s
OpenCmdInCurrent()5 y i+ u9 B* i
{, K. H* C3 C8 L0 i) L
; This is required to get the full path of the file from the address bar( b8 H" ~* p& M! t& O
WinGetText, full_path, A
2 a: i; ]7 s1 r" E9 ` ; Split on newline (`n)
7 L2 @& X& L8 _: M# p StringSplit, word_array, full_path, `n) |# I. g6 Q/ t) a9 U! t
; Take the first element from the array
2 g8 @6 M5 ?& T* X: V* ~ full_path = %word_array1%- b3 }- q, b. i: n
; strip to bare address* W1 ^5 o2 M4 \8 B) I4 P
full_path := RegExReplace(full_path, “地址: “, “”)
' r' b# \) t2 ?( f% V9 H' v ; Just in case – remove all carriage returns (`r)
0 i1 J5 J) x. z/ z( E: g' m! Z f% V StringReplace, full_path, full_path, `r, , all
6 l5 C! v/ O7 b3 n" W IfInString full_path, \# h% ^ j# ?3 @6 u6 z4 F1 a
{& o2 S, o/ r; y* b+ U6 u
Run, cmd /K cd /D “%full_path%”5 h. d& x; K( h. Q- [* ^5 Z+ j
}
7 k) |# t, ~! I: @$ q5 n+ T else
% y2 ~9 }5 r p( }0 d {1 @& r+ z' ]" c- s& M
Run, cmd /K cd /D “C:\ ”' w; k4 T8 E$ k7 S
}
. V4 y: G9 W' Q% O* l5 k7 I }
" G8 D) [ T9 y' n 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。$ Q8 w c5 n L$ d* H7 y
这段小代码肯能有两个你需要修改的地方# y- P; J$ L* P$ [: v3 f! D2 u
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键9 t. k3 H; x2 e1 W3 A, A% Q) ?
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “3 m5 Y3 g( ^/ x2 W* J
|