此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。1 m7 D* e, u# x
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。" M6 A( m6 s6 C: r u5 L; ^. D
方式一:& [" [) X' y1 A/ \$ n2 {6 ^8 C
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
% v3 f: N& \. f/ }8 r( {3 F, { 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和' c# N+ U2 E( h! E% A) s
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
" M" P$ D5 w- m* A( I7 ? 方式二:6 O4 F* i, f8 I3 a& h- K$ I
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
: W' }/ I" M: a8 x) o SetTitleMatchMode RegEx* Y4 x- i: |# b' l' s1 g) K9 x' h4 [
return- I& N* a& d# L
; Stuff to do when Windows Explorer is open$ r1 R1 V- C# X3 ~; z) t
;
! D- J: X, k7 v j #IfWinActive ahk_class ExploreWClass|CabinetWClass
. ]3 \9 d& z$ R( |' M. T ; open ‘cmd’ in the current directory
6 h: H- f% Q$ v! b ;
. `4 W* t" Q* j* h7 ~9 Q8 u #c::
0 s2 n$ e. w. e! ?6 ^5 Q OpenCmdInCurrent()8 ?- R# P! _1 ]) f5 ^
return& b! {, d, u# {7 _$ R
#IfWinActive7 x' q: C7 s k- A
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
& O6 g6 x& z' B0 ~) R t" V+ ~ ; Note: expecting to be run when the active window is Explorer.+ n, P- Y+ c) N/ Y
;& S$ q% y/ O$ ?4 g
OpenCmdInCurrent()
5 z) S3 T" v: k5 J6 o) d {9 [2 e0 ~! p# u* ?5 _' ~; f) a; m( b5 H
; This is required to get the full path of the file from the address bar g! n9 m8 e" q8 e, D! M' p
WinGetText, full_path, A' e) \( ?- F0 m- N
; Split on newline (`n)
; L6 E ~+ m4 q- C$ C( b# `/ [# E StringSplit, word_array, full_path, `n
8 L5 ^- h7 Z3 _) m- |9 b ; Take the first element from the array
. h; B1 h6 S( J9 n9 _7 v7 i" L full_path = %word_array1%
/ j4 ^6 u4 d0 y, } ; strip to bare address% [! A6 Q1 K, q$ T4 y( x0 ^; C6 ~: j
full_path := RegExReplace(full_path, “地址: “, “”)
+ i7 m+ y+ F1 ~! E& a% t4 Y. Z ; Just in case – remove all carriage returns (`r)
4 C$ o7 z0 [8 F8 f9 k StringReplace, full_path, full_path, `r, , all
O; ^2 H* `: J" z Z9 g IfInString full_path, \
! Q. R, l# |: q0 [, @ {/ r6 Q3 ]. T c7 \/ n( `$ h
Run, cmd /K cd /D “%full_path%”2 B- k: _! G: a# L7 t6 R, x8 `
}; t9 N& a* n Q0 X' v5 q# p5 i
else
9 V; m- E4 g7 h7 T, M {+ A& r* U) A8 N" b7 W
Run, cmd /K cd /D “C:\ ”
, T( }& [: G' N+ w, F }
, b- H6 I( E! R8 c }
Y- q+ M% ^/ }5 O ~$ F 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。+ H" G' m3 H ~# j9 ^% s3 d- T6 ]
这段小代码肯能有两个你需要修改的地方5 F+ I3 K: V/ R T7 e a
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
+ n& W8 U1 M L G" L 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
9 F1 ]* z8 c& q/ d! i) l4 d# u |