此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。7 `( V8 E9 ~/ B
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
Z' R( s: C* v w! \# _5 ^2 o 方式一:
& o% V6 {! P% k$ x7 U* D @ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
6 x8 a7 s/ G7 e9 g+ H7 N 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
7 W9 O. R( u" {9 d, U4 x7 C HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
8 @, K- A" E' s. \( A 方式二:
4 p0 I5 E9 C7 z# G/ ^) J 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
& T' _( q) z. x4 ] SetTitleMatchMode RegEx
- Y' @) r5 P9 b3 T# K return$ ^/ M5 C" R/ n% v; a
; Stuff to do when Windows Explorer is open
0 K [' V8 L% r _ ;% \) q7 ^8 Q2 k
#IfWinActive ahk_class ExploreWClass|CabinetWClass! \. M% t5 F8 R+ c [
; open ‘cmd’ in the current directory
4 {) U6 V8 w" E4 D! F ;
$ L, |$ T( E; O T# r5 z #c::2 z3 A, B# l$ ^3 K( x6 A
OpenCmdInCurrent()
; E7 V! M6 M, P0 f5 m* C N1 r return
* W& H! g0 {/ C' {5 S) D( g #IfWinActive
/ n. O6 m3 x( A; J$ B* y' Y3 W6 h ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.! p. D* o8 N+ s6 z; U
; Note: expecting to be run when the active window is Explorer.
: A9 ~" @( ?3 z0 i) T& K ;4 N3 ]* c* G6 d; J* C. J2 o
OpenCmdInCurrent()" m& Z2 W2 h% m- Y8 C- r1 V
{
1 a) h u% B8 L: q: _& O# W ; This is required to get the full path of the file from the address bar
5 w+ h3 J m" Q: K6 N WinGetText, full_path, A$ m5 Z6 K$ u. E6 i J
; Split on newline (`n)# e( K( _; ?3 b
StringSplit, word_array, full_path, `n/ O9 L8 A7 I" X7 @( f
; Take the first element from the array2 |) p0 H) T& C# W
full_path = %word_array1%- l. t2 V7 Q$ o; Y& N: ?$ i
; strip to bare address: K* E. ?9 E3 l Y7 ]5 l
full_path := RegExReplace(full_path, “地址: “, “”)
' [5 }$ o/ K/ d% Y8 N' F8 |: h h ; Just in case – remove all carriage returns (`r)1 ?% P! \. C) z, c
StringReplace, full_path, full_path, `r, , all
3 S3 p: ?. x+ m: H4 _1 Z" w# }* C IfInString full_path, \1 n6 G: y! t, k! C
{ y3 X2 v) l3 ^
Run, cmd /K cd /D “%full_path%”
* p5 Q6 [& y+ {" w$ l0 k; M1 y1 H }
5 f v$ A5 ~# e1 {/ V! f! H0 ]) D else* t4 C1 e" T6 |2 f+ P
{
6 D3 V& L: Y% f Run, cmd /K cd /D “C:\ ”
2 m. a8 k6 Y c; u }" r; \9 t" Z5 q- w; G
}
5 Y' Y. g% y0 e* {4 b0 P- F 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。4 g8 |, K+ _7 @# z$ I, ~
这段小代码肯能有两个你需要修改的地方
8 s' ]' S* H# [" B! B# C: Q 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
7 |1 n9 C; e% |, B 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
6 Y# y1 k" F& g3 t& i ~6 f |