此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
1 N! u) A. T( e; K5 g3 } 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。* r+ ~2 V; q0 @' | T2 D% V. x$ o! i! Q
方式一:
0 {1 E; q. T( I5 a" n! U 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,9 v$ l# q( s, O- W v5 m$ _9 `
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和6 [7 |2 ^) n. J2 N* D) L4 x
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
6 f" K8 S. }5 L9 a 方式二:' { ]1 }: O: D1 a3 p* v: L4 k& f# ]) G
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下: Y" k+ Z5 Y0 A1 f( f
SetTitleMatchMode RegEx$ {9 k1 x! V9 w6 {# A$ {6 D
return6 R4 |0 C1 T l) y) ~
; Stuff to do when Windows Explorer is open
6 R4 x6 n2 [5 r0 x! w ;
' G- v0 J* Y" S k! X' k6 D8 Q #IfWinActive ahk_class ExploreWClass|CabinetWClass P; ^4 }6 z6 ^, V' m& w
; open ‘cmd’ in the current directory% }: U" u. z; x0 I$ t
;
0 z6 t% j" o2 \3 @ #c::% e/ ^1 d' v; B" K
OpenCmdInCurrent(); L) I. D" q* s2 s, {& K
return# C" c" M+ q' N/ w5 R8 a# |1 ^' |' ?% ]
#IfWinActive
' ~% L g$ E8 g3 a4 F ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.% n- I: s% l) V& \# b
; Note: expecting to be run when the active window is Explorer.
) l" ]) t2 {7 B ; ?1 ]: R. ~% p* O5 [
OpenCmdInCurrent()
& W1 Y! e/ ~; M# Q* `. y# A/ O {
+ M3 A9 m- q9 a2 d% H- W i ; This is required to get the full path of the file from the address bar$ m3 Z; H" D, }" _1 I
WinGetText, full_path, A/ H3 @2 r' ?) Q: e, J( L/ A0 G
; Split on newline (`n)
& t/ ^1 O* T5 I; i: R' U) } StringSplit, word_array, full_path, `n% V, ^* z$ Y: |& L/ _
; Take the first element from the array6 R1 R/ N* |; X5 A9 ]5 F
full_path = %word_array1%; p/ I; B/ }! E! `9 e. c9 m
; strip to bare address& E- O, b7 o, m5 Z: a- p
full_path := RegExReplace(full_path, “地址: “, “”)
6 a4 q: ]: g. ?9 {2 ` ; Just in case – remove all carriage returns (`r)# Z8 F. A4 Z+ r( X0 p) _" M* J
StringReplace, full_path, full_path, `r, , all
$ Z K, {$ R) A0 I; B% |. K, T IfInString full_path, \0 i0 _. b4 `6 {4 b1 Q7 [
{
, m* Z8 [2 A7 N" T Run, cmd /K cd /D “%full_path%”
9 d- g7 t6 o% s2 s }
. J; v6 Q) o! O! d5 |4 x else
+ `' E$ v+ d& @, ~$ R. Z+ _ {
) [! ]9 v! Z+ y Run, cmd /K cd /D “C:\ ”
) l( \: q9 ?: s1 _ }
1 k" D( D! O) y {& `% m$ Y5 Z }
# I) p- y1 y3 D8 t# `5 U9 ] 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。6 M# ]7 n2 J, J2 k8 w% f
这段小代码肯能有两个你需要修改的地方
- j' i! L& Y4 r c0 P0 \+ J6 ? 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
3 h- p6 W$ b' Y, i 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
9 O0 r7 i, e. o2 \+ t, S( \ |