此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。1 D0 J: A% ~6 X( R5 P# N1 f" Q
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
, N: ]1 d( B8 W p2 y+ n 方式一:
c/ `5 r" F) U: S 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,% K0 W/ r) s9 V. h# p; {
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和, H H% Z* x6 k9 b5 \: H% g# Q* O7 E+ I
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。* a; w8 p2 x4 e
方式二:/ R1 m. P2 [5 r9 u% ]+ W. W* g$ O" J* g' F
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
. N- ?" u4 d2 m, ^/ x, E SetTitleMatchMode RegEx9 {. w: R/ V+ c" D: o( Q- Y' I
return
' O) Q# Y; |( j3 @$ O; _ ; Stuff to do when Windows Explorer is open
! G" p, [: p) m3 p! l- W, J1 u1 C ;( B+ b4 d L' W7 y8 l. c" [
#IfWinActive ahk_class ExploreWClass|CabinetWClass
+ E6 i$ V$ U3 s( e# B ; open ‘cmd’ in the current directory* _4 M0 H! b6 ` q2 R5 d
;
% v7 ^. R+ M8 ]+ [ #c::1 [" h: z# R/ e$ r F
OpenCmdInCurrent(); M3 S5 k x8 G
return
" h2 b5 X3 S1 c2 p# J& t; D #IfWinActive5 [) s7 P1 ~! c, ]8 m, A
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
1 \9 ]+ d! w' ?" W* y* C! k ; Note: expecting to be run when the active window is Explorer.5 i" t" }% W7 w$ v
;* j/ \: |# k/ k Y9 b' K
OpenCmdInCurrent()* x+ n8 t8 R6 R7 F7 B
{
' l: h' m2 ^5 _ X ; This is required to get the full path of the file from the address bar- X. Q+ H' N# ^2 w
WinGetText, full_path, A* k# g6 c A5 x: }/ w2 Z
; Split on newline (`n)4 v/ Y9 S; w, p( }+ D. V
StringSplit, word_array, full_path, `n
' U7 `. _, H6 c9 L b. z ; Take the first element from the array" j0 K4 m- T3 u
full_path = %word_array1%1 p, A3 x3 ?' H2 l% Z `
; strip to bare address1 `8 h" i, \5 l% @1 X
full_path := RegExReplace(full_path, “地址: “, “”)
6 F- s0 j$ u1 F w! p# F ; Just in case – remove all carriage returns (`r)
9 v3 M: C4 S& Z; e/ U StringReplace, full_path, full_path, `r, , all, \ y, J' u X
IfInString full_path, \
: u7 t; k* P% _" o {
( R8 q% O) G5 n) x( q Run, cmd /K cd /D “%full_path%”/ \/ B* a& }9 }
}5 e! m9 w' s1 t* T I# V6 _# }
else2 o# X% u1 ~, t) L! w
{8 L+ \# |9 p. m7 J D3 Y
Run, cmd /K cd /D “C:\ ”* b5 M& z9 h* t8 n- Y
}
% H$ H! B( W' l4 t) |) A D }
0 }1 |6 H U; X( B7 i 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
* J, ^' N% c3 j; m% a& _) w Z 这段小代码肯能有两个你需要修改的地方
( T# x& ~, Y0 V/ ?5 T1 l 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
1 z4 S( \5 ^. y$ D# b 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
+ r; l& p! }" i% s! @ \, P4 v |