此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
6 u& G: Q. W( h- J' k# j5 \% i 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
/ i! N- l# `, c; ~- U" h 方式一:
( W' ?3 Y# S5 V# J( f8 p" U 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,- s/ G/ A9 @1 @4 [
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
3 O% ~" H1 ^1 W6 J d HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
( j8 A' ^' b+ {) B2 ?1 Q 方式二:$ z, |2 S- v, J5 T1 j/ c) X7 P
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:$ M" n: N. G% s: {
SetTitleMatchMode RegEx
; q3 X* s7 H Y+ Q% g- G- t return
6 c" d* R+ e7 b2 c& Q& z ; Stuff to do when Windows Explorer is open, Y% r- h# E# `: q4 r: O4 c4 n
;0 ?( n" H1 h. a* d: T8 E
#IfWinActive ahk_class ExploreWClass|CabinetWClass9 P8 H( n0 K5 ?7 K
; open ‘cmd’ in the current directory' N' D- a% q8 [' `
;: Q; o( ~" J6 R/ i0 r
#c::+ [) `* ?, f4 i
OpenCmdInCurrent()
8 \' d7 V, `$ p% Z' L return, I5 c2 o& K J' f" C/ ^% E
#IfWinActive! O" ^3 {: C$ a0 I) M; }. {% q
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.. y" J8 v4 s/ t! w5 I$ |1 J2 Z3 j
; Note: expecting to be run when the active window is Explorer.
/ A) u# X5 s s2 c6 L. Y' m3 g2 o. F ;
/ [! M5 O- M$ M( h6 K2 K OpenCmdInCurrent()
) r6 Y1 J9 M. R {) f5 m. f- s6 R
; This is required to get the full path of the file from the address bar
- g% c8 _: K# k; d5 I- P8 ~8 q# q' M WinGetText, full_path, A1 \; d9 j, _* l% r
; Split on newline (`n)$ }1 W( R( B. c- G. @
StringSplit, word_array, full_path, `n7 }" G# m$ @" Y5 o- ?4 l1 B" G3 @( s" m
; Take the first element from the array
3 P1 A* m5 f; `! X8 ^. P. E# w full_path = %word_array1%& }7 L$ t' V- J5 n& B
; strip to bare address
" F. ? x0 K! i full_path := RegExReplace(full_path, “地址: “, “”). @$ c( T/ i) w/ u. S7 \" r8 G
; Just in case – remove all carriage returns (`r)' i, k4 G ~' i% V% b/ K+ V6 p* N
StringReplace, full_path, full_path, `r, , all" E( _5 _) ^* G/ u& g1 T7 [
IfInString full_path, \
6 @" N9 ]; [- }- k } {
# m, D$ W: s7 q. S$ d Run, cmd /K cd /D “%full_path%”
' J! d% `, g0 ^4 Q" Y3 p5 A# S }
5 p! r# l! Y7 B/ q+ d. k, B# C else* Q Z' \- b8 \6 M1 v
{
7 z8 Q8 t) G! o0 A+ ~ Run, cmd /K cd /D “C:\ ”
" p/ s: o$ a- ?& f }
( N- d7 k/ h$ m- c }
6 ~( k! |- K( ]& l5 i 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。 D, a* w5 {4 v0 b e/ s: i
这段小代码肯能有两个你需要修改的地方
9 U3 e% a3 ^0 V) I3 p( r 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
7 k& ?# q" l7 c* S: l- T 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “, z+ q* T5 \$ r" P
|