此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。8 {: B) P7 E3 E* n0 r8 v2 n& w
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。) i) ^- _: n1 S+ s- |( g/ r
方式一:
1 V6 w2 g, y% m; o& l3 ] 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
& F+ p3 Q3 H0 Z; h! s 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和6 y g/ l- }! X0 Y: ]1 B/ \% [
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。6 J/ ` y7 G' { l( Z
方式二:$ x+ f. a; }4 Q* S9 [$ K% G7 p
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:0 u8 O2 i( j& q; k# {$ w W( |: z9 j+ R
SetTitleMatchMode RegEx
* d# x/ m* e* h return, N& x/ u$ M% _9 F2 [
; Stuff to do when Windows Explorer is open
; S( K% ]+ N9 U' h& Y2 @ ;
. p" {2 Q; Z* j) [& { #IfWinActive ahk_class ExploreWClass|CabinetWClass, |, T* p: {, d* D2 s0 b
; open ‘cmd’ in the current directory
! O! R: s' d- g) l ;- z- y3 Y/ Q& b0 Y; B
#c::
& i4 }+ W0 e/ a$ J) o OpenCmdInCurrent()( C7 Z1 }% S8 v! ?! Y4 q
return6 Z7 R1 _# [6 |) k+ a
#IfWinActive: t. Q8 U' _2 d; i# o
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
3 q) I: u# C Q3 l- e- m ; Note: expecting to be run when the active window is Explorer.
* x$ w) g* d) w0 o ;
3 e+ [, a) |- d! M& H" ` OpenCmdInCurrent()' }1 [% N Y W" G* `8 J, u
{3 e: }/ k0 C( @- P2 W, U, x
; This is required to get the full path of the file from the address bar* X' I k: p0 r$ l' s* z
WinGetText, full_path, A4 C2 e: V$ o9 W& U I
; Split on newline (`n)3 ?5 N0 I. Q, _. u) R. ]3 v7 x
StringSplit, word_array, full_path, `n; u$ S9 M, Y5 m
; Take the first element from the array% F3 } D9 h: m/ _0 S9 p( C
full_path = %word_array1%
. V7 ?8 L3 E) n" j ; strip to bare address, w7 K! {- u. R
full_path := RegExReplace(full_path, “地址: “, “”)
$ ^+ S* P- J4 F0 K, Y ; Just in case – remove all carriage returns (`r). D, H& m# h# @, ~& V }9 A
StringReplace, full_path, full_path, `r, , all
8 K1 ~ D+ q- F; R' }7 b! n IfInString full_path, \; E" L, F* R, {0 y! I) N! e
{7 h# C$ Z! J" f
Run, cmd /K cd /D “%full_path%”
5 Q! v. N* q r" [8 C5 \ }
8 \( L; y: U: ~+ x. u% w8 I else: h1 y: ?; W, C. H/ F
{
" E6 Q! y# h# [- w2 }! W% _ Run, cmd /K cd /D “C:\ ”
0 p U: r4 d- O, X! X& t* s0 c }
4 f" H* J( u( f2 F. S: p* z }4 @2 S& E1 O5 i- u1 E
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
; j s4 Q9 G6 B0 a# h$ W& n 这段小代码肯能有两个你需要修改的地方
% B1 G7 `( q' f) j- |. D 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键 ~+ J. g, D, b' ^: h( \
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
- V1 B4 U- d: y% d |