此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
3 P% ~* i; b" d6 i( k 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
" R( ]% w+ M5 |9 q5 A3 a9 P 方式一:
( M6 e, ~* T3 d, s( m- S 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,9 X. ` B' V6 _- [9 r8 f
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和* @3 _2 [) s6 q- C+ @. A7 O
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
( V, n2 s; _- [ 方式二: O. I8 @" q3 E* f
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:: G6 {+ Y# A5 O
SetTitleMatchMode RegEx
' o$ ?" ?% I# J: H/ M* h return4 @' P% R, j) |8 z
; Stuff to do when Windows Explorer is open9 j4 g6 q0 \& U4 p k. s
;: `6 t ]# }" z2 v- ?7 B; |4 Z
#IfWinActive ahk_class ExploreWClass|CabinetWClass% d, B! K! u4 s0 U1 S0 u
; open ‘cmd’ in the current directory
6 a* P1 s% [, u! @+ w ;
; N4 r& X/ R( W! j0 { #c::: o) B4 f. v( {6 S
OpenCmdInCurrent()
7 P* z8 w1 q8 P return
2 J' D6 ^5 Z8 M5 d1 ` #IfWinActive9 \0 r0 B' f. W/ I: Z/ y3 k- N. [
; Opens the command shell ‘cmd’ in the directory browsed in Explorer./ W! M5 N/ g3 m8 y6 h
; Note: expecting to be run when the active window is Explorer.
- ?; [2 H8 i/ D5 R ;( i- }. Z9 L( v$ W6 i
OpenCmdInCurrent()
7 C2 [7 `3 l/ Q$ [/ f# ~% F {
a% c) k- [- ]8 _3 M+ v- L ; This is required to get the full path of the file from the address bar' D+ ^* w$ I9 y! h o
WinGetText, full_path, A0 z3 o' M) k4 a6 k0 B0 G, C4 o4 q
; Split on newline (`n)
. B$ U: h B" e8 `, k1 C% v7 i, w! O StringSplit, word_array, full_path, `n5 M+ u( a. `1 h4 Z# Y0 f! t
; Take the first element from the array
1 p5 }: {2 G2 m' h2 u full_path = %word_array1%: d4 Z( Y" K+ M2 V
; strip to bare address0 W: i3 E7 c( N2 ]* N! ?5 ]
full_path := RegExReplace(full_path, “地址: “, “”)7 B5 } H* M0 |. F% T
; Just in case – remove all carriage returns (`r)
/ g4 V& ?# F) c' C/ W& r9 c( d StringReplace, full_path, full_path, `r, , all
. ~; |( S! t, G4 X IfInString full_path, \
' `. c# f8 _. z. a {" o" \ d- e8 a
Run, cmd /K cd /D “%full_path%”2 x/ Z- }9 h2 K! v, s
}2 J( ~0 b# l% y8 N$ c
else3 q* W8 N% p7 Z# F K
{ J9 K9 [: m' n2 v6 F
Run, cmd /K cd /D “C:\ ”, Q) n; M2 |* R+ r/ T" w
}
5 q2 G5 E* C6 U( F; W& q) X4 q }
2 X! E' E; C' {6 s# L3 m o; t/ M 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。1 u& C/ [/ p3 m5 A
这段小代码肯能有两个你需要修改的地方( r& y! o4 a; x# b" c6 g6 D& v
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
; ` K, I" t% e- \0 S4 S6 k- a$ k 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “ d6 o" d) S' \( v; Y' E v4 m
|