此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
# J/ i- H8 u, d( k5 V. j 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
$ B/ f4 z0 b; s 方式一:
% `# c* v! s3 [1 I 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
7 s9 c% h9 K! @- ` 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
8 c1 k( M8 O# A8 D# T$ D0 c" o/ B$ } m5 [ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。, {9 z/ i, a, h/ w
方式二:* v7 D: \2 `, W7 W" ~0 Q5 _
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下: J: _) o8 E/ N$ `9 X
SetTitleMatchMode RegEx( y2 R2 f; C6 y" N1 f
return8 C/ u1 Z4 V F$ Z
; Stuff to do when Windows Explorer is open* k/ E2 i2 C4 _; l
; ~0 v B/ Y+ W8 N& K
#IfWinActive ahk_class ExploreWClass|CabinetWClass$ _/ C. } \1 v
; open ‘cmd’ in the current directory* _) W6 u; `+ F" H" l( Z7 c
;5 p, e) r0 d; U+ l! R8 T" H6 u8 Y
#c::* @6 i, P1 y' C2 S i* T: F q; s/ g
OpenCmdInCurrent()
7 G' o4 _. X& w return
7 i, D+ [, e4 O( x' a #IfWinActive$ G' J8 |7 K/ p5 a
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
) p/ e* r7 e( m1 [1 ? ; Note: expecting to be run when the active window is Explorer.
+ N+ g, E m& f* j% u ;
" [. E9 X) Y0 A/ } OpenCmdInCurrent()! M. u) V- s7 k% ^5 |! z1 P! T+ n
{) ?& h& N9 i1 C& b
; This is required to get the full path of the file from the address bar$ o8 ], H& H' n
WinGetText, full_path, A& Z* U8 e! `, o+ i9 a4 o; b" q
; Split on newline (`n)
2 l/ k, b; K, `2 ~; u, O StringSplit, word_array, full_path, `n6 m( ^! Y" b* c6 V% b
; Take the first element from the array7 u- x9 T" H; O0 ?8 k
full_path = %word_array1%
+ m& G4 b/ X! M6 S5 C0 i! D ; strip to bare address
8 w( `. }; y& L& K. _ full_path := RegExReplace(full_path, “地址: “, “”)
0 Z5 Z( Y# z% @% K5 q9 N, c/ i2 n ; Just in case – remove all carriage returns (`r)# D4 F C+ J. B! ~; Y! V& _: R& t
StringReplace, full_path, full_path, `r, , all% x/ k* X. i L+ E f
IfInString full_path, \
0 x6 Z4 q# ?' }& K {
, D' @( T1 m) a1 C Run, cmd /K cd /D “%full_path%”
$ D. d+ C% S# r+ v6 |. W6 n# Z2 X }
* R+ P0 S% L7 w6 N$ h else5 e9 u* m& p& [
{
; L8 c R( v/ W& e Run, cmd /K cd /D “C:\ ”) r$ A! Y( [( h
}
9 y4 B4 S& k. y }
8 e* p- Z6 k) k2 {/ L: X! w 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。8 g, m- z$ P% e+ }
这段小代码肯能有两个你需要修改的地方 r0 Q, a0 f( V3 U) t4 r) ~
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
E1 V, D0 ~5 o 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
: `9 o# x+ I D) ^7 m/ w# |4 b4 g |