此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。/ _7 _2 R0 a. n4 V: ]
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
8 Q. n, U. b% h0 _/ }% \7 F) Y; { 方式一:/ o& H9 |' K" i# P; W3 D) E# o' k
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
; |; x, h+ R/ y* m! { 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和' y9 V5 e1 c9 ~6 T
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
/ A* x/ G# G0 w7 W' E0 l 方式二:
5 H1 O8 L1 |- B/ K( F& o8 g! d3 g( T 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
z- G; U r7 l3 @ SetTitleMatchMode RegEx
0 [: Z% W+ n2 n8 Q* P3 P return
; s9 O2 D& m9 g) p; e ; Stuff to do when Windows Explorer is open6 A3 U; j+ q u8 {3 {8 O% j
;& g {" x1 ?" a5 M4 M* }
#IfWinActive ahk_class ExploreWClass|CabinetWClass
5 L7 d$ e( N0 e% F2 S9 u2 k1 M ; open ‘cmd’ in the current directory
7 z2 |; s" ^7 s- j9 f ;
4 ^/ y4 c7 |! P8 \ #c::& E) u! B5 f- V
OpenCmdInCurrent()' }. `1 j. F: G1 \' I
return2 X- `. y% _! m1 m
#IfWinActive
2 m1 B) j% `) Q7 H ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
5 Z1 N" `: j1 J7 D/ g& c: C3 O ; Note: expecting to be run when the active window is Explorer.
9 m5 {( D/ y( n" e! B ;4 q& O. e/ Y- b6 }1 ~! N
OpenCmdInCurrent()
- g0 e- x3 b' a0 B B {! d1 |- z+ @# w2 _/ h
; This is required to get the full path of the file from the address bar
. `* ^+ `; A2 z3 ^# Q$ I& d WinGetText, full_path, A6 s- t( [1 c3 v" q
; Split on newline (`n)6 l0 ^. K% g J9 I, @& j6 l
StringSplit, word_array, full_path, `n" v) i2 J0 b- S( s% z4 u
; Take the first element from the array! ~8 J$ O" |7 G- [3 j7 V
full_path = %word_array1%) i5 E7 f' b) b' E
; strip to bare address; k" G9 {6 m+ F& V& Z+ d! A' ~# ^
full_path := RegExReplace(full_path, “地址: “, “”)9 ]( l" P! I' L( Z& t+ A/ k
; Just in case – remove all carriage returns (`r)2 T v; z9 z6 }$ K$ P0 e6 `' \
StringReplace, full_path, full_path, `r, , all
1 x" C6 T1 o5 O% c) B% b IfInString full_path, \
; `$ H/ U1 B. m5 L+ x# K {1 p# _. T) _0 x4 V; n
Run, cmd /K cd /D “%full_path%”
4 _, G2 e) o) R3 Q }9 s7 K. g- R" @6 y5 l* s
else/ _- r5 n# Q3 Q/ N
{
1 V& i# s4 a0 X3 p! ~ Run, cmd /K cd /D “C:\ ”
9 T( [% X& s6 \% ?3 [- W9 j1 A, j }
. B0 I, `. A3 O8 [ }
- @* v$ |! n* [+ X' j 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。% Y/ Q8 G) Q$ ^4 O
这段小代码肯能有两个你需要修改的地方0 C2 E' P. @1 G1 ?3 j& n. i7 M
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
" [" {! k( u- R. ] ^% c 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “7 d" b) E2 d" e% J, U# \
|