此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
X1 b3 V5 Z! }( q( |( i 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
" Q% T- S$ V' c! M6 u 方式一: ?* G- C# v% G
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
1 @' F+ ]8 R. E" ^' s5 q 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和+ A3 w" `5 I" @
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。1 Y7 B6 J5 D5 A; M* R' O2 b
方式二:* E- r, X) b3 N
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:8 p* D# `7 I5 n2 r
SetTitleMatchMode RegEx+ q: m% L. I/ T$ n z
return- R6 M8 |4 B1 _) G5 A* \2 T
; Stuff to do when Windows Explorer is open
7 W+ }% h/ ` d5 `/ ^6 i! R" f ;
# M; J$ ~) n$ D1 P6 \9 [6 Q #IfWinActive ahk_class ExploreWClass|CabinetWClass: V2 I# R. W$ S/ l2 ~7 R
; open ‘cmd’ in the current directory" U7 V) {/ P9 d
;3 |5 d# `& ^# u; I3 k
#c::; g/ \5 v* u& l6 C. M5 w, r- ?& [2 D" i
OpenCmdInCurrent()
S ^* d& {- }' M9 b7 a6 J return: i7 e0 h' G1 y3 K* ~
#IfWinActive$ i! [8 t+ v6 ?% \7 |! Y% D) P
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
2 G# V# F/ h w" ]9 Y ; Note: expecting to be run when the active window is Explorer.
/ [- @/ H, @7 _5 v% { ;+ ?% V- A. Z4 h" s% E
OpenCmdInCurrent()
9 E( r3 Y& [/ w7 Z9 w {
/ Q) Y: b+ E& L* h/ w( w7 l ; This is required to get the full path of the file from the address bar
0 `( ^1 M( d# h6 [# o0 Z; K% d WinGetText, full_path, A' {! O8 M" _+ r+ K9 B/ V. M7 W3 e
; Split on newline (`n)4 }+ P4 o4 `- T S6 n
StringSplit, word_array, full_path, `n
* n, c* b$ D1 \ ~ ; Take the first element from the array; }7 k* h5 W5 v2 e
full_path = %word_array1%
5 Q* z( o8 X2 X7 Q0 s+ u: O ; strip to bare address3 Z$ P3 M* F8 [: r7 F
full_path := RegExReplace(full_path, “地址: “, “”)
; g ?. m" o1 h1 G; L0 |/ S ; Just in case – remove all carriage returns (`r)
+ o! J* X! I1 k, c$ _0 V StringReplace, full_path, full_path, `r, , all" r+ ?- {, O7 k6 x* l( U6 I
IfInString full_path, \( X \* O4 Q/ s4 g. V# `8 T: q
{9 Y; @0 i; s$ J0 V* {
Run, cmd /K cd /D “%full_path%”
3 Z+ W# h) {+ n }5 K" {9 u9 L. h% D& F0 A
else: H& m0 f" c1 X, O& K' i
{" l5 n' |# a+ B
Run, cmd /K cd /D “C:\ ”2 ^ r+ U; Z: f6 u! x! P
}
9 P# m/ P6 Y a4 o }
5 @& j, X7 e a# s2 R 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。- f* c% @* t& d, T. i& y1 A
这段小代码肯能有两个你需要修改的地方/ {/ Q$ A" x/ b# [8 d" T. }
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键( ?7 e% w% k) \# V7 R2 z
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “$ K. y( f) c/ U* G1 \+ a* I
|