此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
8 g) X1 y6 W, [2 o- }5 ]* |2 g% ] 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。, c! [" _9 n0 p, G2 n0 h" M6 N
方式一:
0 O2 m2 K1 c; X3 d7 X, R 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,/ F+ I( T9 p& i! S% S1 I
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
7 x; ?. t- L) D: N9 b7 \7 C4 t HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。* k/ o# I* h" ~0 `1 [/ L0 c) t
方式二:3 x4 i: k+ \1 T5 p' d7 I* m
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
/ _& P2 ^. u9 d `4 ?8 ^7 u SetTitleMatchMode RegEx
, P S- G, I9 G+ u* Y! `/ S return
1 P& \$ W/ m- W. c9 P ; Stuff to do when Windows Explorer is open
* ]5 J# G) O4 ^ @5 Y ;
5 ]5 i7 b% {- C \% L #IfWinActive ahk_class ExploreWClass|CabinetWClass
# P: x! m: `5 A- O) R1 @ ; open ‘cmd’ in the current directory
6 M+ k' K$ R7 ~. l4 z* o, O ;' }) |( N& v# m7 P1 _' f
#c::
. y q/ x, ~4 t% D! t OpenCmdInCurrent()" o+ s7 \. c/ E' J- Y. F _+ r+ i6 u
return7 x: B$ V+ [$ B" Z' L( F
#IfWinActive
+ Z) l b5 N, S ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.) ^6 R- g( i+ F8 h) l9 R9 J
; Note: expecting to be run when the active window is Explorer.+ n8 H$ g ^- t7 F: {& M* m/ v
;
4 {0 u- H# i$ f9 I9 e" x+ w# c OpenCmdInCurrent()" C% p: V; ~1 |3 [8 a8 w8 s
{
, ~( C7 ?- k( L! N F ; This is required to get the full path of the file from the address bar
. A, l2 H0 a ~8 ~: b WinGetText, full_path, A
) g6 ]. v$ Y/ B" |1 Q ; Split on newline (`n)
9 N& n9 ?) ?/ k* \2 }6 m StringSplit, word_array, full_path, `n
: w% U% `5 u) `! e ]1 V ; Take the first element from the array; C) h F6 W5 H% l I% S
full_path = %word_array1%
: d1 _& F- E# Y3 j: K ; strip to bare address5 h' p+ p q. C2 [
full_path := RegExReplace(full_path, “地址: “, “”)
& P+ `$ [& ?4 u) f) c" d% T ; Just in case – remove all carriage returns (`r)- x, T9 b* m1 r- |5 s6 U5 ?1 `7 r
StringReplace, full_path, full_path, `r, , all
5 }. z4 D) [+ p; M. z4 q- P! g- _ IfInString full_path, \( B' @' e2 e4 ?9 K: N
{; {) ] N( g2 Y% F
Run, cmd /K cd /D “%full_path%”
. ?2 r3 O3 Z+ O1 U6 ]! Q: e! S }
: j, J. z1 i: B% c3 d else8 x' x. Y$ n: H" c" C* B
{, K2 d- w- T) z! h1 E0 `
Run, cmd /K cd /D “C:\ ”& ^; D& Z' s% @
}
. C9 _- n2 q1 K1 B. b }" R/ v( V; ?5 z, [
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。' `$ n3 j# O0 l/ d' r8 s' u
这段小代码肯能有两个你需要修改的地方& W( z0 q: m& v3 u2 w
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
. _* N+ |. t+ y ?. Y9 `6 D 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
8 O$ e) j0 X8 \. n |