此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
, O( i: ^! h' H q 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
6 }" K0 {- B4 f% x" `% X: l3 q. j" N+ X 方式一:" v$ K' y2 X" q: s
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
! v% Y8 x) X; ]0 A- ?3 J 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
8 v ]- R t; t( F3 G HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。6 H. t1 @+ ~8 x: M) S
方式二:
" O! p3 p" X R( m7 j 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:/ Q4 u9 T2 v. G. i% s+ b6 Z
SetTitleMatchMode RegEx
9 x/ P9 n0 Z) T' z4 R: l return! a' `: U- y0 H" k
; Stuff to do when Windows Explorer is open: ]; U1 Z7 Y# o( P3 ]" j
;
/ e' Q t9 m+ j! W3 J #IfWinActive ahk_class ExploreWClass|CabinetWClass8 P1 H! h/ y) U( \
; open ‘cmd’ in the current directory
/ q) U) N# o" A! u8 v ;2 a* a# Q3 }$ U9 w" l* P
#c::
$ g5 ~$ j5 b7 Z+ C; |4 k OpenCmdInCurrent()1 P/ {6 `5 [& m6 w* m9 u$ k9 {
return: Q3 ~' D8 S7 U- l. z+ P
#IfWinActive
/ j( q5 l1 a; n ; Opens the command shell ‘cmd’ in the directory browsed in Explorer." m0 V/ H( C* w( f' S4 o% e
; Note: expecting to be run when the active window is Explorer.2 ]# |, o8 v/ X M* T. E/ ?/ _% L/ |# h
;: f; U6 i6 w9 n# @4 z% H; d1 J
OpenCmdInCurrent()
% b- K1 @# f K {+ q! c" @; Q1 P8 C/ y: K- W z* X
; This is required to get the full path of the file from the address bar
$ _8 O' D$ h& I' S0 x4 \3 J( B3 Y WinGetText, full_path, A) R( o, j6 w( y% p4 z3 M8 m
; Split on newline (`n)4 [& W! ]4 m2 E+ E6 }7 [' V
StringSplit, word_array, full_path, `n
6 ?0 e0 S0 _' V+ O* C. v) g" p ; Take the first element from the array4 ]* S' {2 @* r
full_path = %word_array1%. e; D- `, d" `8 M9 A
; strip to bare address$ f. \( o) t9 ?7 U$ I! J
full_path := RegExReplace(full_path, “地址: “, “”)8 d* y1 U* O M' s9 c# f
; Just in case – remove all carriage returns (`r)0 V5 e0 P) B- v; T) A7 d6 r0 s& ^6 K
StringReplace, full_path, full_path, `r, , all6 f( ^( t: p8 `4 w9 h- C
IfInString full_path, \+ R8 N ^! D: h& Y
{
/ }) E( l' w; m w Run, cmd /K cd /D “%full_path%”
e- ?, z+ C ^ }; R, U& \& t* G3 U/ W* P' e
else
6 T8 K. M/ m( u6 l% A# X9 ` {
' L: @, N( m- r& @ Run, cmd /K cd /D “C:\ ”
( V" F$ H2 u0 ?! l( m; N }
9 |/ h" n5 [/ |* v. k( \" n }. C* b; Y: B1 {3 V: r
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
) d4 O/ W% Q8 e1 B, l7 { 这段小代码肯能有两个你需要修改的地方
7 S) v, X; W& A: y* t( g/ Q% l1 A 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键& P& S1 q9 x+ ?% F9 C% O
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
8 y3 |+ Y' E$ q1 ~/ A |