此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。: i4 a: }( ]( _) j o
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
9 S. \: i' H2 k$ f7 e! i1 g 方式一:
4 p. |' v; K( f0 I 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
" O) d; A; I; ^* l" {6 i. K9 h( T 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
; W F# F! [8 C5 V f) Q HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
8 _" Z, [/ r, o( [) Q 方式二: {9 M/ ^2 b4 V" h& o9 Y
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
; J: n5 K* [) \: a SetTitleMatchMode RegEx2 E' P0 e$ y6 F( c/ B0 F0 U$ h& c
return V8 J% I1 o) |, K j$ B) F
; Stuff to do when Windows Explorer is open
b8 X2 V+ p1 f3 q: [. b* @ ;3 x" \' b; M7 T; H0 e% T4 L( n
#IfWinActive ahk_class ExploreWClass|CabinetWClass
M' R& Z k$ e6 H- d+ r ; open ‘cmd’ in the current directory" l6 e& h: S- g$ I5 y0 M8 l
;
6 _' z, c1 X( F+ Z- \ #c::
7 l' l. P+ J! `6 P OpenCmdInCurrent()8 p. w1 n, t; s0 J8 ]
return% p2 x& x, Q. H' ]1 n
#IfWinActive
. v, Q' a3 ?6 Q( G9 k( j ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
# f! N8 e3 X e* ?, X ; Note: expecting to be run when the active window is Explorer.; n- G% y1 f3 N. C, x
;
. y8 C$ p9 ^; L: u3 ~: e OpenCmdInCurrent()
U b, _+ v: B/ x+ k# u9 E {
0 \4 f/ m& O1 R/ c' k ; This is required to get the full path of the file from the address bar: A( k1 c4 n6 D; l* F8 O0 d- n
WinGetText, full_path, A3 l) Z A- B- [7 h# @
; Split on newline (`n)
5 y" z5 }- _, u3 d) d2 [# B# ~ StringSplit, word_array, full_path, `n; u* X* D# n8 v) T$ W7 A
; Take the first element from the array' z* S j4 Q3 G l0 |
full_path = %word_array1%
4 u: Y* \7 W/ H) A" x3 f ; strip to bare address+ ?5 Z4 N) g5 [3 z7 N6 B3 f
full_path := RegExReplace(full_path, “地址: “, “”)
- o0 u- m1 W7 p/ I) Z' F ; Just in case – remove all carriage returns (`r)
' E# W- w$ Q- F; @4 }* ] StringReplace, full_path, full_path, `r, , all
( J9 M; o% V* w6 D0 d6 [ IfInString full_path, \
1 h, M* x9 y! b/ m& R/ ^3 x {$ g* F, y* T! M0 N) V& B
Run, cmd /K cd /D “%full_path%”
9 I+ j% T* U5 C( N9 N }
' e/ R* u1 e8 U; p" | else
( N f- v# n' O1 N& V+ U {
- `; h% w+ w) j* P0 H$ S Run, cmd /K cd /D “C:\ ”
, x, @/ e3 f. N( B m* i* [ }
2 j$ V; o1 Z# B. ^' \ }
0 @% |: \5 s9 @. O: F* D 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
2 i# j# d7 `' j. f 这段小代码肯能有两个你需要修改的地方
/ _0 b7 h# ~& B: \: | 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
$ t4 M1 X, g' a3 i( U& l1 f 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “1 D( B$ k( @; f+ u
|