此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。5 j4 X! v0 U" ^; [8 v- S' A
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。! x# I) G4 W# H
方式一:$ f0 w, l3 ^4 V! R$ i1 r: _2 p
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
0 j: V v+ H9 w 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
: | O3 L2 p4 N' r9 I& [# k L HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。( o( S3 a* N' f E' X. ^/ N' @/ ?, Z
方式二:8 S' j0 Z/ E3 q1 ?; g
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
( l- w& X2 V! z7 k SetTitleMatchMode RegEx
& W j4 Y3 u2 N9 J' Q) J return
' t i. h) X. y+ ?. t) Q ; Stuff to do when Windows Explorer is open) G' N8 g4 W+ w! V# m# l x
;
- h! J; i3 R' C! J5 l #IfWinActive ahk_class ExploreWClass|CabinetWClass# R7 o) ]9 n/ Z; [, I h# M
; open ‘cmd’ in the current directory
: U/ n3 U& Z( l ;
6 S7 y& E/ ]7 Z6 X4 A) G #c::
8 m) P, e0 ]1 ^# b# |) R8 t$ m) N: C OpenCmdInCurrent()
+ ^$ l% E( ? Z. k& Q return
" g1 |, S7 N6 w4 L #IfWinActive% y) I5 \+ L @, G' O' ^) s" e' q
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
) n2 U; N! [1 B" C, k ; Note: expecting to be run when the active window is Explorer.: q' `$ L6 Z Q, C$ y2 P4 k; @* M
;4 P1 N ?+ \- C1 c/ H
OpenCmdInCurrent()
3 F) z; J) S: y4 M( c# G {2 `7 w) F( P( c# E
; This is required to get the full path of the file from the address bar
6 [2 p6 K, a; h! Z WinGetText, full_path, A
* M# s0 v+ b: o, K9 q ; Split on newline (`n)
- {) @/ Z0 u1 f$ w( a2 Q StringSplit, word_array, full_path, `n9 g. }. `. e0 S, @2 r$ A' [/ b
; Take the first element from the array% B- M" _. O3 c: w
full_path = %word_array1%
$ @% v' `, r4 Z$ z; B. z- R ; strip to bare address: b0 c& g7 Z' a- z" \$ m2 ~' T
full_path := RegExReplace(full_path, “地址: “, “”): c/ S9 v- I6 w
; Just in case – remove all carriage returns (`r)
% q; q! m5 t5 B& ^ StringReplace, full_path, full_path, `r, , all# ^0 ^/ h. X+ d' ^% W" n6 X( Q
IfInString full_path, \% `+ k& R+ i. x1 A
{
) M# Z8 L3 m( u" r" P6 N Run, cmd /K cd /D “%full_path%”
/ X F2 d. T& o9 E1 W& A2 P }8 W1 \( p( {% z0 u$ g
else* V7 b3 ?3 w; w( q* @$ ]* T" L, u2 w$ @
{4 r: _" f# x9 _8 C& M# N5 T" d% o
Run, cmd /K cd /D “C:\ ”
$ a) Q/ c* H, t/ X* } }# T3 D0 o) u) x, J B+ @! \% E
}- d: M0 o0 R5 }/ L ~ b" F; `
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
9 q" ~- t+ \% T7 L: j. D) ?# j 这段小代码肯能有两个你需要修改的地方
2 S. u/ I( U" f5 o" r 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
; B" p7 b2 V9 m7 f' V3 m 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “2 d+ S3 ^/ w% U) G: Z) |
|