此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。8 V# E" n9 d7 n6 `: l
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。( N' L) h; z3 T: a! i
方式一:! F" D; z% j5 s8 T) Q9 m- z4 P2 J( _
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,4 |) e" Z4 t/ H X* I
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
9 J/ l l' x: I HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。) W- k4 A4 t6 F/ n, X J
方式二:
3 q/ E) J- Z. l6 f* o( c; \ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
, ~/ e- a0 ^& U# a# P' w2 a SetTitleMatchMode RegEx
3 b9 d2 G& {( Y+ }) ^ return
2 _, V: Z5 @0 {6 h ; Stuff to do when Windows Explorer is open+ M: h, E0 j( B+ M- Z
;# M, N) p4 B+ _! _1 Q5 O
#IfWinActive ahk_class ExploreWClass|CabinetWClass* b' N: h1 [/ F# `
; open ‘cmd’ in the current directory/ {) v3 j$ n4 U. h; P9 |
;/ d& \( G4 E' ~/ a! |3 u
#c::( [# v6 e" p8 G! q9 e7 y6 ]
OpenCmdInCurrent()
8 [4 u/ R! V' _ return3 p+ g- L/ i/ N9 I& f8 M/ T6 F+ Y
#IfWinActive, z/ h8 W$ T; V+ X4 o2 e5 h. w
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.0 L2 i P# B9 N" O& J" N4 h
; Note: expecting to be run when the active window is Explorer.- s8 D, w5 ]3 F# t r) T/ B4 Y! T) p$ d
;) i* j* O: S8 W4 a8 q" u
OpenCmdInCurrent()
" j# m- j) p$ ^7 f8 H( O {( U6 P: z- f; e. b# S
; This is required to get the full path of the file from the address bar
) ^+ Q2 C% W3 \6 Q# I WinGetText, full_path, A+ q5 C: ~" Y; }1 G, V" l
; Split on newline (`n)
5 v* k+ R1 d% \ StringSplit, word_array, full_path, `n o" w9 ?: Q% l# O5 j4 g; ?
; Take the first element from the array
0 h- K) ]0 N% @3 \, _ full_path = %word_array1%
1 s( B A! x# Q ; strip to bare address
; e8 j8 l, S) X full_path := RegExReplace(full_path, “地址: “, “”). ?: O; ?) ?% g- l: o
; Just in case – remove all carriage returns (`r)
. g# _2 Q" k' F/ I StringReplace, full_path, full_path, `r, , all
2 P9 S, U' Q+ t+ {6 w& f IfInString full_path, \
) P; r, ~% X) R, n( g7 _: { {% }0 x: L9 V" p% I3 |! q- B
Run, cmd /K cd /D “%full_path%”1 c7 T4 E4 q/ N6 @
}
4 C0 T, v" _4 q6 \. ^' w5 F% K else1 y1 a q, p' r2 P3 ]
{
! s7 j7 m0 r3 F8 q Run, cmd /K cd /D “C:\ ”5 R1 i4 F" B8 k% t& r
}+ ` y0 f/ K5 o9 K- p! k1 X" T: g
}
0 h; Q+ E* T) q5 h$ f 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
5 i9 z. p0 @7 j8 p4 O3 U L 这段小代码肯能有两个你需要修改的地方
3 o5 r; F0 z) ~( }8 g9 g" t 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
) F) }' c1 k) u9 C' {- [7 t$ i# C 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
6 j8 H4 f, r- n6 H+ l |