此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
0 V; X/ C. M+ Y 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
6 l9 @9 j7 T; T 方式一:
, h- d i, P w# ? 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,8 n) D' F" t& W8 |9 G
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和0 u- Y1 G$ S' S
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
+ P {; @& L6 {5 s5 s+ v2 H' [1 p 方式二:
6 |# t# {0 j( ? 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
" b: G% |: M# m/ q8 D SetTitleMatchMode RegEx
3 s) J. D% u' l- g. O+ l return
# k% a6 \3 B3 O ; Stuff to do when Windows Explorer is open
4 Y( H( v4 ]" I ;% Q5 j% P/ ^* L; C# \* e
#IfWinActive ahk_class ExploreWClass|CabinetWClass
; `. g1 K& w" w3 V" t% T6 R ; open ‘cmd’ in the current directory
+ ^7 o2 [ w' i ;
+ r0 }8 A* H$ T! p# r8 s #c::
$ f% o% K* j; {& m OpenCmdInCurrent()
5 u, |# J! W9 C" p. K return( L; f8 j) r3 D$ `
#IfWinActive
0 a) E+ p3 d3 q) h8 Z `7 Y* \ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.% F3 C4 D& q/ }! D9 h
; Note: expecting to be run when the active window is Explorer.
0 G* r. O7 m$ a8 `) |: @ ;
& l! A0 i& k! O( R# {" M OpenCmdInCurrent()
$ r* e7 I# N ^; R6 M. z8 x {
" a5 y I: B" [3 n. z$ O U% X ; This is required to get the full path of the file from the address bar4 z' d# I( ^/ E+ Q
WinGetText, full_path, A' F# c/ I5 _: y" ], a j. G
; Split on newline (`n)
5 B9 t- Q1 {! k3 x2 G, u StringSplit, word_array, full_path, `n: H1 N0 k0 o# z% D+ }( x
; Take the first element from the array: G: ~' t3 B% b/ w3 P' }
full_path = %word_array1%. {1 W' {/ t& y% {$ i, p+ c
; strip to bare address8 z4 [: y$ f# q) l0 ^: j6 h$ t
full_path := RegExReplace(full_path, “地址: “, “”)
( F' |: @0 w( O# s! u, v4 ? t ; Just in case – remove all carriage returns (`r)3 n/ g0 C! _0 j0 e) e" {
StringReplace, full_path, full_path, `r, , all; b+ p# ?7 J" ]( m
IfInString full_path, \) k- K; H6 V3 o$ F% S
{& b$ o# G. g9 \! A8 E
Run, cmd /K cd /D “%full_path%”! m" B/ P+ `) a7 a) _# ^4 s7 v& }
}
. z* g# D0 u( |0 M: B% r% \% K else
' Y3 m, {! o' W; V3 x {
' P# o. R E- ~, g2 O) A, v Run, cmd /K cd /D “C:\ ”
" e( W- \/ m& U3 o! a }
* K* Z" U8 g+ A: P2 {) `- g }. J- } }! {2 f% ~
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。) v/ q( u" O7 s' o9 R( K6 O# b& f
这段小代码肯能有两个你需要修改的地方: B2 e( Y, {8 G; M
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键! o. F* f5 B# b; \
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
$ L1 z. t# ?0 p! u/ T; {" B0 R0 n |