此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。% O7 ^9 d8 O# x/ I2 a) y W
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
' x8 E) H# G& q, C8 q% A, \& F 方式一:
' e6 M# E* X) J/ I8 o, q0 b: e 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
4 @- }. B+ B* R" A: W 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和' i/ G% k8 c4 @% B# I
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
& f: ]- l# R$ Q5 _. h9 J: E 方式二:% {' G- y& {8 v+ s4 b/ v: G
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:2 T1 m) L+ }6 {9 i x7 n
SetTitleMatchMode RegEx) z$ N2 R1 N |; P
return
4 x- H: @. ^; @9 @' ]) h ; Stuff to do when Windows Explorer is open
8 r: W) r9 k! G. r% ^ ;' d) y- L) m6 }; U
#IfWinActive ahk_class ExploreWClass|CabinetWClass* `8 m9 K# a1 _* H: L( o
; open ‘cmd’ in the current directory
8 U; k& c" G" N+ [ ;) \% U+ [* \: D$ O; `- M
#c::
6 ?/ V& B2 I3 h1 R OpenCmdInCurrent(). d% U$ e3 b4 o7 S- f" M2 }* @8 I
return
* X" g" Z- ~' ]: { #IfWinActive& }' r* t% z! }+ ?4 ~8 C
; Opens the command shell ‘cmd’ in the directory browsed in Explorer. w8 \$ | I2 j. u! N! `2 Y1 ]
; Note: expecting to be run when the active window is Explorer.
|5 t! |0 I4 X! @ B/ T ;
, \% X. m2 ^& g9 K OpenCmdInCurrent()
' \( Q' [, ^0 Y* W+ H) ]0 I" n" A {1 x; T, }% E. J- J# o
; This is required to get the full path of the file from the address bar
, g/ w. @! {& _6 H! Q WinGetText, full_path, A) Q; v: K5 e8 N" }0 Z9 F
; Split on newline (`n)
\5 W7 c/ [1 c6 p, y StringSplit, word_array, full_path, `n
1 W+ {" K( {6 Y6 k: @$ h+ ] ; Take the first element from the array4 Z5 H+ J. \/ w. b( a
full_path = %word_array1%: l' b* }" M* r" N4 ? Y" s8 W
; strip to bare address# \- _ A7 M3 \# `1 F) o
full_path := RegExReplace(full_path, “地址: “, “”). c% D8 M; D9 q6 z, q, B1 D5 Q
; Just in case – remove all carriage returns (`r)
0 w$ _4 m% S2 R6 h StringReplace, full_path, full_path, `r, , all
( | @5 J+ E9 w! V! f8 ?# B IfInString full_path, \. J. \" w P3 {$ M3 `! p
{% m8 L- C# B3 s8 {+ e6 Z
Run, cmd /K cd /D “%full_path%”+ t7 h/ f! ^ w3 _' u' f4 g) |
}8 {7 o& y. f0 P; d. l+ a% T+ x
else
( }; \9 U( V& v- I {
1 Q' f! C v3 }2 |% U. m2 }: @$ ? Run, cmd /K cd /D “C:\ ”* Q9 s2 i* }) f& s, B; [0 G$ m, g, R
}
. ~; _- p, }. G2 K& B$ l& C- u }
8 ^1 {8 j1 z/ m% y 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
- D1 a0 S+ K' N1 g 这段小代码肯能有两个你需要修改的地方
. d" k' h8 w) X& f$ K7 m z 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键! R/ Q: U, [- t5 i0 r1 e
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “' ?; ?* d% n/ I* P: K
|