此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
- f% H2 D5 j8 ^8 Q# U( h$ E8 H7 W 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
9 `1 Y0 ^9 t0 h6 d 方式一:8 F* }: ?. B5 U+ d
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
3 E0 D% g4 T7 i1 L 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
) e$ k$ ?5 @3 N4 H HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
/ x' P* L$ X( T/ x4 L 方式二:8 L% L/ \9 w* _( \4 x6 o
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
# ^0 N' r, g1 l, B( L( E SetTitleMatchMode RegEx
' t* N: Z% \2 C1 G9 G0 @* l return8 ]6 ^$ P( H: X& T/ p! E* M
; Stuff to do when Windows Explorer is open
$ F* W( L3 }( e) l9 g ;- z4 i& ^" Q! p# G. L. q
#IfWinActive ahk_class ExploreWClass|CabinetWClass& M! u0 J/ k: b
; open ‘cmd’ in the current directory8 T* M& v6 |8 c/ c9 c. ]7 N1 b' w
;4 F* e$ Z% i5 H3 a+ G$ Q" c7 ~' c
#c::; |8 k" g# A3 M+ y6 @! U
OpenCmdInCurrent()- }6 b; X1 j3 @7 B5 U5 F V+ x
return9 P! \7 E- i8 u, \7 q X
#IfWinActive
: ^8 j1 L8 g6 _! @9 A ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.5 Q' `1 n: D2 e7 r2 K1 m
; Note: expecting to be run when the active window is Explorer.
; F- {3 b M2 C- e8 O9 F. n ;* f, G' e& Q0 z7 G# _
OpenCmdInCurrent(); U2 R6 W4 W, B9 y1 V
{- C. V+ e- W! @! f# ^
; This is required to get the full path of the file from the address bar
9 R, u6 U6 Z6 `0 b, q WinGetText, full_path, A
% y" `9 ]4 M( @1 P2 ?- f ; Split on newline (`n)
# B, ~4 {: K( B0 Q, g, B/ L StringSplit, word_array, full_path, `n) C1 N! D6 ]) i+ T: a
; Take the first element from the array
; B( |" L+ S% |0 P4 q full_path = %word_array1%9 r5 j/ l* y# ?1 _7 ~
; strip to bare address4 m* S* P y0 a4 s& [3 A9 I/ Z
full_path := RegExReplace(full_path, “地址: “, “”)! `. Q% s U9 a# @- u, b3 q% _
; Just in case – remove all carriage returns (`r)
. P i, G. L: Y$ B StringReplace, full_path, full_path, `r, , all
; ^) K- h" E+ z R N3 Y! a; f IfInString full_path, \
( Z( }) Z: r) `5 t4 p% J' r4 x {
- D3 x9 F# F) o" i) W Run, cmd /K cd /D “%full_path%”3 L* z9 |& W8 s; z
}0 `! h9 g3 X0 K* k. _3 x8 E
else
8 ]2 \ r% y$ L1 Y; |9 o: D } {5 g/ }8 E9 X) U4 U. p; O& u7 I
Run, cmd /K cd /D “C:\ ”
; u/ r, g2 B* q8 ?$ {+ t6 g" ~! l }
( m* N+ s$ i. ]; \# ?, @5 r8 s: i }
2 G: I* D Q m S9 S9 X 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
/ e, w% K$ B( C- G 这段小代码肯能有两个你需要修改的地方1 z! j9 S, k! g" y
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键- ]6 | h2 j, a' p
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “6 ~% s& Y, f( z3 {; n) A) N
|