此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
! o. \9 b9 Y8 S6 G; d+ | 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
( l1 O9 x( j7 E7 D! k7 u 方式一:
$ ^# ^* G# [# }3 y 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
5 m; d& C5 p2 k0 x 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
- m: n$ h0 Z& [, S$ v+ C HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
8 M, ?, Q( M5 X o 方式二:
4 H5 [" A# K* { 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:. s/ K( H2 k- j- g4 V( e7 @
SetTitleMatchMode RegEx p+ D4 @! p* h b+ O+ y' |
return/ l q4 u1 u) }7 U a
; Stuff to do when Windows Explorer is open
; q9 e( g8 A, E2 i2 G/ S3 Q2 H- [ ;
$ g; F2 Q8 r4 Z #IfWinActive ahk_class ExploreWClass|CabinetWClass
5 h9 A1 `0 B l# a* i' W* T6 S# K ; open ‘cmd’ in the current directory
1 g b3 J9 ]7 J# k0 U ;
i- ?/ Q9 T% x% K' f4 l) H #c::% n* K/ v I. n& Z# E" v
OpenCmdInCurrent(): i8 K8 H# Z: ~6 c8 |
return7 L. ]7 j$ Q2 F# k1 W
#IfWinActive
0 s- l8 i7 K% D, w' q' g* g3 h% } ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
) y- ?: {3 U) V: L ; Note: expecting to be run when the active window is Explorer.9 V+ E- i% T6 w+ D) Q6 v
;. [' z0 i3 i' Y' g
OpenCmdInCurrent()
C% h% ?& ?/ O" ]- S& ]5 X3 n {
) ~/ n& }/ G8 b; V W6 J ; This is required to get the full path of the file from the address bar
- m7 W6 b, y1 Y3 i; W3 E& G WinGetText, full_path, A' t+ C( I- }# ^$ h2 J' }
; Split on newline (`n), S7 k! ~' H7 P5 f3 k
StringSplit, word_array, full_path, `n) Y2 y! h0 t, k7 r% L& Q+ A4 ]
; Take the first element from the array
( ?1 |; K8 l) J9 R full_path = %word_array1%. R* t4 {2 P4 U& t7 S. O# Q) ~
; strip to bare address3 d: {! j2 I* e9 D' [1 ~
full_path := RegExReplace(full_path, “地址: “, “”)
' P4 r- ~/ n3 e4 Q% e) k ; Just in case – remove all carriage returns (`r)
" T2 o7 n# d' s8 ? StringReplace, full_path, full_path, `r, , all4 [4 M6 f3 e3 t( \3 n, j2 W4 G
IfInString full_path, \& v8 }1 j/ M. ?* s3 t' ?! A
{% H, {8 Q! Y0 ^) }& @' T
Run, cmd /K cd /D “%full_path%”* t- T* W; X! T' G8 w
}
' y* j3 G! K- T( `( _ \ else
/ Q1 h7 I$ @$ [; |$ m% t K {5 U' e% h6 I4 ]1 F1 `, l2 v# `
Run, cmd /K cd /D “C:\ ”3 B( @0 U6 e' ]3 t8 B: I! H/ @
}# V+ L- ~0 i9 D6 V% a
}. U I( N, K6 m* n
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
* W! i- h! H2 J9 E! b, M 这段小代码肯能有两个你需要修改的地方) z% e& s+ X0 _$ E! }
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键3 I$ l0 h( M( Z+ @" H& r. R0 C
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
! M8 l/ ^) o+ m8 r |