此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
6 G5 d6 r0 R7 K4 U( p- E0 g. @5 D 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。. Z% G9 e1 J- ?0 J6 b
方式一:
5 x$ B6 n4 f4 }; r: u4 N 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
$ s. R F. K {9 Y! B 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和* J, v# u0 B* a8 O$ C
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。 ], N0 G0 p3 j! L, e
方式二:) t5 z8 g) C- `3 p. z
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
1 A' H0 Q. A! O8 c( s; e. w SetTitleMatchMode RegEx
: X+ h5 E$ Z( `3 _ return
8 p/ c3 n% e4 r+ u7 C1 E, @$ { ; Stuff to do when Windows Explorer is open" q- D1 V9 R5 |. U L8 c
;2 ]- u2 y4 s2 L7 j: d* f
#IfWinActive ahk_class ExploreWClass|CabinetWClass
" N* ?6 K2 S3 P9 |7 V0 \* j3 b ; open ‘cmd’ in the current directory
: K d, c( I& z+ [, o ;
: m* b+ M6 q; P; a+ k #c::
8 a5 E% D$ N b. G( Q; Y! E9 y OpenCmdInCurrent()! m5 M' m, i! `9 O% j& C: Q
return( C$ x4 M/ e9 Q/ Y
#IfWinActive
3 V ]- {" V' A ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.5 e9 m0 o- S$ S+ I& T* K4 S
; Note: expecting to be run when the active window is Explorer.
4 e& G$ e% ~+ u4 r" s ;" Z3 a& {* }% q1 k \. c
OpenCmdInCurrent()$ e; ^8 o( y. c# ^
{
" D! U4 ^1 l% l' y% m" _- m ; This is required to get the full path of the file from the address bar
! S8 h1 N/ L8 }* D WinGetText, full_path, A
6 D9 H' W- [6 W' n ; Split on newline (`n)) c/ H' I2 ^ w, o% T
StringSplit, word_array, full_path, `n/ v/ r, v/ l7 P4 `$ F* F$ z/ s* N/ a" k
; Take the first element from the array
( Z( B& e) a/ Y/ e4 M full_path = %word_array1%0 r. j" K3 n. `# U( o
; strip to bare address7 |+ n! E) _6 y$ E& ^3 a: H
full_path := RegExReplace(full_path, “地址: “, “”)9 {! j1 z& F L7 y) @+ r H
; Just in case – remove all carriage returns (`r)
( U; l2 z+ J7 J8 E- Y8 R0 l* U5 T StringReplace, full_path, full_path, `r, , all/ i2 ~0 Z/ _0 w C% x& [# v1 u
IfInString full_path, \/ Y1 b" E$ Y; \" ]) j0 ~
{# u; j1 v/ j* r( W$ S9 ^
Run, cmd /K cd /D “%full_path%”
+ T, Q4 q/ @; G% T }7 ?# _$ \0 }1 t5 n
else# p t, t1 p: q0 o1 o: }
{* o' h; e% w: F; j: n w$ i# h1 f
Run, cmd /K cd /D “C:\ ”
, F! g( m. }, \, [ }% _2 g9 V, d: U3 _ ]" o
} h, ^6 X' ]. k7 l
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。& I6 M/ {! @4 ^- T5 c
这段小代码肯能有两个你需要修改的地方
7 `: n: j5 B/ w3 P/ |4 @ 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
3 |2 Q) D; M" E0 Z) t0 _ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “) \4 J B/ q3 k3 B+ U
|