此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。. d" x: N' w* a9 `: X; [
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。: P0 O8 T# J1 Z& R( a; g9 C8 F
方式一:
; Q4 {3 S$ |; a 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,, Q0 Q* k j. v* l& b% r
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和- [ q& @8 e, o& K* b
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
- A! P8 c6 H+ `+ p% T 方式二:
0 ?% R, q$ k* | z' G! ]$ W 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
/ l7 m( P" W+ |2 e SetTitleMatchMode RegEx+ `( ]% o0 P1 d& j3 ^+ F
return
7 s, W B L. p! r4 @ ; Stuff to do when Windows Explorer is open
! T& b' L- L( c: \2 P( I ;) p7 W! O R9 T; [( q
#IfWinActive ahk_class ExploreWClass|CabinetWClass
6 z' C+ t1 X; { ; open ‘cmd’ in the current directory
/ c" Y) P! A9 M ;
) A+ [5 I& P, Y; B. j1 @ #c::2 T3 T1 a0 B0 U$ U1 k
OpenCmdInCurrent()3 A) S ?: j8 m- b w1 }/ G
return
8 k6 W" w3 X- X, l7 b* G: ~ #IfWinActive
; E" p- m% M# S2 G! Y! D ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.* N+ F0 B. E5 `$ ^" d7 m! l
; Note: expecting to be run when the active window is Explorer.6 b4 X/ a( u5 U9 I0 C6 X. M
;( }5 ^: u; r4 S' J, a# k6 a/ S$ r
OpenCmdInCurrent()6 {) c7 N( X; @$ I+ o6 n
{1 f, v) ^* D4 h1 z A- }+ }
; This is required to get the full path of the file from the address bar
9 X) i: G1 c4 V/ ]1 f5 X5 }7 ^/ ]' S WinGetText, full_path, A" _ t! v$ u8 A$ R1 }1 p+ m
; Split on newline (`n)- T9 u8 M% g/ M9 v) x9 f" O
StringSplit, word_array, full_path, `n
: J2 k) j8 w" ^) ?; C- B7 ~$ E; Y ; Take the first element from the array, ?5 |8 y5 y% n$ v
full_path = %word_array1%5 ?! W. @* }# ^+ Z* v
; strip to bare address
# u0 W$ S) B* s6 H) V v full_path := RegExReplace(full_path, “地址: “, “”)6 g% o, N6 D( f0 b9 s/ g
; Just in case – remove all carriage returns (`r)) G9 Q3 d9 M5 T8 T
StringReplace, full_path, full_path, `r, , all
9 s' v# N1 ]( V: A$ I IfInString full_path, \; n: N' S5 H: T5 s; \: ~
{; {/ P/ c5 O. R8 t; C
Run, cmd /K cd /D “%full_path%”
3 ?5 F9 n' o; g3 b1 l3 |5 E2 r }
) S4 ]+ g& u% T* E5 G: f2 b7 X else |) n, X0 @& n, j; i- V# x
{
7 N( N2 y7 l, h+ a* @ Run, cmd /K cd /D “C:\ ”
5 l& c% K% k$ Y: J+ a }
) n5 o/ `+ q5 x }6 d4 l% f* S O( r. ]
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。1 L' ?& K) r0 ^7 g
这段小代码肯能有两个你需要修改的地方
9 J/ S; W8 h$ i$ R7 H 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
; }6 A$ |" x$ B5 H. V" a 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
) d% j4 T9 r+ x. Z: M0 V: U. f |