此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。. E! |8 i% d5 A& ]8 ~4 l- \3 C
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。" I J' d$ s9 T5 H4 R1 L" [
方式一:
, D+ R5 F/ s r; F- D$ C, _) E 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
& e, H" u! n+ F- [ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和0 n. t) B: w2 @4 h, ]/ _/ o5 d6 k
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
1 h2 Z2 ]' y1 m% v 方式二:- D/ o7 C8 J+ P0 K, e8 u
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
3 [% M$ T3 H! ^0 Y8 P: s4 L SetTitleMatchMode RegEx' `$ g: G2 d! C% m0 {8 P' K4 ^9 ^% |% \
return5 V3 x' V& l1 l6 F- H
; Stuff to do when Windows Explorer is open) V5 E3 ]: t. w G
;
4 F% A! z) W8 x: P6 P5 t #IfWinActive ahk_class ExploreWClass|CabinetWClass
' U! r# E) ~" J- S" f8 |( ~. l ; open ‘cmd’ in the current directory
3 I- o; Y3 W6 n! J ;
7 U( ~ u1 z3 Z: i #c::
, ~+ u4 G) Z F: C OpenCmdInCurrent()
& j* Z" H( ?( J! n- l2 v O return+ o1 I$ S: D. z+ A" u1 y H
#IfWinActive
# i$ s) {+ C. _6 T7 x- Q ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
3 }" m: x! u' l( i4 z7 t# q3 [# @ ; Note: expecting to be run when the active window is Explorer.& |- M; T1 S9 Y# ~, z; w
;1 t3 M" r" c2 ?
OpenCmdInCurrent()$ w& t0 `' K& ~
{
" I$ e U4 i) u( Q! v; R ; This is required to get the full path of the file from the address bar- w0 O" a" H/ p& w K. V9 ~
WinGetText, full_path, A" h9 D4 Y: t3 o
; Split on newline (`n)" }9 h7 A! l# t- n( T
StringSplit, word_array, full_path, `n/ ^4 i! k P7 y$ g7 Y
; Take the first element from the array
5 c! N. y# `! `6 Z5 V' l0 F% t full_path = %word_array1%
: F e9 I+ X7 n7 A2 R Z6 Z ; strip to bare address
* D6 r5 i, ~, k, M' ~" V full_path := RegExReplace(full_path, “地址: “, “”)) m: E/ s- q4 V2 z4 F* v
; Just in case – remove all carriage returns (`r)
2 `% N( F" q# o( H: |/ g' e; Y StringReplace, full_path, full_path, `r, , all
+ L. G' [' ~& g( y' t& K D6 r IfInString full_path, \
6 U9 |# v8 p# q4 R O3 @ {( a3 H8 x: l+ {$ F" a, E$ L" P
Run, cmd /K cd /D “%full_path%”& ?. d2 E" K4 R% l" M
}% F0 H4 Y; J# F( u4 [" p
else; {+ c; ?; j+ `3 W+ {$ B2 W- n
{' ^/ u/ C1 Z: D+ m1 u- r
Run, cmd /K cd /D “C:\ ”
1 _; J3 ~. T; I% O# p$ a' X' C1 L; j }+ x' ?) D/ S: r: J& K6 a6 j/ b& Y
}( Z, L2 a: v# j$ n, v
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。. H5 A# _2 A+ V3 o0 {7 [3 W
这段小代码肯能有两个你需要修改的地方6 ]% ~& f8 s8 |. B$ l$ ]
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键) S# K& u! h3 h/ G1 ~- _
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
& m! I# s1 E7 ? l$ K; E, B+ `3 @ |