此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
$ R" d" W! r- I 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。5 v( e' }% S* L/ w% H# y
方式一:0 b6 E, n/ k$ B( j. Z) _+ W
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
3 Y. g2 T7 t* S% O3 r/ W4 e/ r 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
3 n' x, W d1 _3 N8 A* i* h HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。1 o0 B* w( [0 S9 T8 d* W, k2 E) D. r
方式二:" l+ F" Q, R- Z$ u$ Q
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:" m* y2 |& w% ?4 m
SetTitleMatchMode RegEx
' J& \; C( Y6 V( j! B( W; h" D return
3 w6 [6 G5 P) h; t h( v/ a3 a O ; Stuff to do when Windows Explorer is open
. ?& ^. i6 g* V7 y ;, v) ^+ n0 J" n2 H3 r( ]) h- X/ v
#IfWinActive ahk_class ExploreWClass|CabinetWClass3 n/ Y) Y: R) P& i+ K! @2 I
; open ‘cmd’ in the current directory9 c; B' D6 \$ e
;
+ O2 e' L! b9 n9 X6 u W #c::5 J" r" H$ T- B! j v& y1 G8 {
OpenCmdInCurrent()% B2 K1 h8 n$ c. w) E% b
return4 w4 v) ]0 |, N+ _% z5 ^0 J
#IfWinActive$ ?2 t0 j; w/ r/ o( U; o) V
; Opens the command shell ‘cmd’ in the directory browsed in Explorer., Z" S- s6 H3 |4 ^! T
; Note: expecting to be run when the active window is Explorer.
8 `7 l% |2 W7 J" ^, P ;' ^, z' L, c8 V$ K- g4 W) w
OpenCmdInCurrent()! d; r0 W" m1 g& ]
{" L" p. v C3 F; x- b3 A
; This is required to get the full path of the file from the address bar# C. N1 x0 }" R1 m1 l0 S
WinGetText, full_path, A
( w2 G0 A5 }3 m/ m ; Split on newline (`n)
3 R1 A+ v9 A5 ?/ `8 S StringSplit, word_array, full_path, `n
/ t2 N l P* ?# r, s ; Take the first element from the array
" U! t+ ~8 j& | full_path = %word_array1%( a. h7 }/ F8 g! O& ?" Q1 k# [; Q
; strip to bare address0 S4 ]9 d/ A: G+ U! {& q
full_path := RegExReplace(full_path, “地址: “, “”)
7 p9 h; p) D) l( t1 V ; Just in case – remove all carriage returns (`r)
5 `- ]* X+ t `7 W% H6 ~( q+ N7 ~ StringReplace, full_path, full_path, `r, , all m' k) ?3 L: G+ b' U& d2 ?7 `
IfInString full_path, \" Q1 y9 `2 {8 h
{3 K& ^ o" Q( W
Run, cmd /K cd /D “%full_path%”; s# X, J+ {8 }) U
}. C" Z( ^4 z4 a i& U) ^1 l
else
' s: L" ?3 S6 l0 c0 I) J9 t {; @1 ?& m Y: T8 o) q3 p
Run, cmd /K cd /D “C:\ ”
- ]9 [6 b+ }7 e C; H6 s }
1 O/ ^; @' [# w4 r4 ^ e& k2 U; a" ^ q }- l. ~5 X. _ i+ h
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
6 }+ o2 u/ `/ y# l8 p7 v0 R 这段小代码肯能有两个你需要修改的地方
% A. R) T3 ^ @( v! u' s1 E5 b 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
" u }+ S+ G+ {2 S3 H+ j7 z 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
' P# U: E$ q' W6 { |