此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
, h6 z3 }2 W* B2 l1 l/ N1 V6 ^" b 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。& X* @5 R9 ]+ B7 ~7 E
方式一:
\1 u5 ~- r( V7 A8 |7 |. u k 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,. f8 z8 V" h' M' E5 ~
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和+ E# v8 {& p4 m7 _4 U
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
1 k: ^% a, }- t, l 方式二:
% n% k/ Q# E, R8 _0 B" ^# V3 W. e 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:3 j/ b+ r7 t! k1 l: d
SetTitleMatchMode RegEx! }) U0 w6 O. S* ?) x
return+ M' a+ \& ?. {! [. d
; Stuff to do when Windows Explorer is open
/ J6 Q' }& e' Q8 }3 q ;) y0 X6 K+ h, ?0 n* x
#IfWinActive ahk_class ExploreWClass|CabinetWClass( ^& [6 V5 L8 ^, a1 y% Z1 B* \, N" m
; open ‘cmd’ in the current directory- v+ v. D. Y" {7 d
;
7 C7 r% f8 f, q& s+ A$ Z( L #c::2 C+ r; l# G0 J+ _' y f f
OpenCmdInCurrent()
* n5 W( ? q; p$ w3 v8 L G return5 `+ t$ Z9 E( t) |% k( ]
#IfWinActive
6 d# S$ c4 Y8 e& f5 y ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.0 B6 N1 ?# }, J/ q0 H5 e2 D
; Note: expecting to be run when the active window is Explorer.+ G" ~! b7 L1 Y! W
;
: E2 R* o1 q( q, X OpenCmdInCurrent()
' \- W# _/ N' _$ l. L2 Q( T; v {" x3 d5 ?& k2 `: |) F9 \. C" m
; This is required to get the full path of the file from the address bar
; E [9 q" J" J WinGetText, full_path, A' I0 R7 }1 E. D/ @
; Split on newline (`n)0 W( s9 l2 Q) F( ~( R9 W, J: p- j
StringSplit, word_array, full_path, `n, _! s P5 i+ f3 k
; Take the first element from the array& @, ^ a4 @; m4 y: J& ^" i& w. \
full_path = %word_array1%$ x. H5 h8 u% L7 q* W( l
; strip to bare address: C( Y; E: @, j, i/ K
full_path := RegExReplace(full_path, “地址: “, “”)! w k4 Q2 l+ d* C" E! {
; Just in case – remove all carriage returns (`r)
' K! T, N' \ e8 C5 E" z) y StringReplace, full_path, full_path, `r, , all
/ ^/ ]) h. f' A, i- ` IfInString full_path, \
* J0 I0 z% `+ H0 P; h {4 Y, Q- E9 R# u- O# X% Q, I
Run, cmd /K cd /D “%full_path%”
' N6 F5 t9 N3 I; D }
0 p) I9 Y- ?5 J/ f else D. E% H2 D0 f: B
{4 z4 d& _0 t& y) h) w6 v
Run, cmd /K cd /D “C:\ ”1 t# A* F& Z# M/ ~8 W
}- M$ V- p) g$ f( @) ?
}
) P2 y; { C4 T2 A2 D% L+ q/ j 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
3 n. T* _; P' V& `4 ~; D) y 这段小代码肯能有两个你需要修改的地方
# y, ^9 L" g- X; L 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
! E) Z9 ]$ E- o 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
0 l' D# b+ S. j1 d7 k; ^' d |