此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。& H4 q) i+ d _* S1 K' A9 C4 D
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。% c, [" F) Q5 T+ P: `$ p
方式一:
* P B6 Z% i* M T 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,9 I) `1 l2 X" Q1 U" M
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
; v+ X$ y7 ^1 ^4 m9 _ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
8 M$ [/ e0 e" g! J$ v# m' Y1 ? 方式二:5 t, R( @* x0 _
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
# C* v. W. g4 v. b. Z SetTitleMatchMode RegEx
' ] C# c5 Y7 O7 N- N) s return' m+ Q2 \6 }& c! d* n' D: q( N
; Stuff to do when Windows Explorer is open
+ t, A5 o1 v7 Q" Z$ o+ ` ;* j. n' X4 {# a/ W
#IfWinActive ahk_class ExploreWClass|CabinetWClass
# a8 C* E/ n( e ; open ‘cmd’ in the current directory. x. {7 P) V; r$ p; ^
;
" _) j2 @, q* ?7 m2 Y8 U/ Z #c::/ G6 h- {$ m& p, F2 I4 O
OpenCmdInCurrent()( M. ]: m* \' ^" p; R
return
- E& U" b4 W5 l3 m+ G- D; ` #IfWinActive% G' W& p1 {# M1 H: a$ \
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.8 A$ |6 r* B3 c( d
; Note: expecting to be run when the active window is Explorer.
! l5 p0 o0 k; e& k3 ^) l- M1 Z0 ?2 v ;* d5 y' r. z5 Q7 c' d P( p1 X
OpenCmdInCurrent()
8 c1 Q. A& F v8 }( k {8 W8 G& [' q9 x% n1 N0 @7 `
; This is required to get the full path of the file from the address bar1 M. l0 ~3 g' l0 R# A1 }$ r0 _/ y
WinGetText, full_path, A! }6 A% s- v0 \6 R/ ]8 l1 p. `
; Split on newline (`n)8 u3 {$ ]' D: V6 s! R7 o' `
StringSplit, word_array, full_path, `n- X" k! h8 `5 O. r3 G. n
; Take the first element from the array
5 T* X j2 F! N: o- k; X! _% V full_path = %word_array1%9 A+ j9 Q7 h! ?/ V0 k
; strip to bare address
7 z6 [* [5 O% Q- ? full_path := RegExReplace(full_path, “地址: “, “”)- {$ J$ U4 T( f3 Q/ J# J
; Just in case – remove all carriage returns (`r)
; ^7 W8 i: d, r: l: R9 Y StringReplace, full_path, full_path, `r, , all/ x& s7 f* v, x$ T( t2 Q
IfInString full_path, \
: O) z: V% U! \" a {
' `7 z2 M3 T9 Z H- y2 R4 p) ^7 H Run, cmd /K cd /D “%full_path%”
" x$ c& B8 |' X* Y }
! o9 E: t% T1 f3 `# ] else
8 T# \. @, V& G. w+ a {/ F% q. m; H+ H9 N
Run, cmd /K cd /D “C:\ ”. N+ H$ \ e5 c5 \8 P( t
}1 }' A$ d, T0 Z! v
}; `8 [) M, V- b- |- e
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。* G" ?$ ]3 `* R2 F- t) e- X
这段小代码肯能有两个你需要修改的地方
( e' \* B! u* P 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键6 ~/ B: u' c# {0 E7 n6 i
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
9 i. [0 o% ~# L+ `$ P( L |