此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。) b, v3 T" M, ~ Y" t+ I# n
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
& H; F) R4 @; s$ V2 N 方式一:; Q9 k) }" ~5 X }
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
4 m* ?) t9 U7 r 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和: j% b8 }+ o; a
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
6 {' R( ?9 _* X' L% Z' M8 m/ T 方式二:
7 x8 ~* q2 y; [) I! } 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
* c0 n h! f+ n/ O SetTitleMatchMode RegEx G( H v3 W: H& Y
return
( L4 d4 T f1 [4 D1 D+ J* i ; Stuff to do when Windows Explorer is open
5 O' y, _. E [3 O ;
3 Y- p; V! N3 ~- g* ]) U' l #IfWinActive ahk_class ExploreWClass|CabinetWClass% H: c4 [: W: t7 c* B
; open ‘cmd’ in the current directory M' b4 |+ M+ C- m( D9 X, i
;3 g& R& Y* }! y' A; [
#c::
3 Q- c' q4 m9 K: P Q) e OpenCmdInCurrent()1 B! B I* c, m* `* n1 X4 i
return
5 o" f; N. M2 m& `' X% o9 m #IfWinActive% `$ ^, Q6 h* [% e) ]
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
8 H4 B. N' N, c0 D, D ; Note: expecting to be run when the active window is Explorer.. p8 y+ @% O# q. f
;7 s5 U% j' R2 }- m" m& ~
OpenCmdInCurrent()* Y7 ^" q" i; i
{1 ]" m6 [8 G- G3 u. P/ q x1 e
; This is required to get the full path of the file from the address bar+ U1 a2 [2 v, i1 E
WinGetText, full_path, A8 p1 I2 f0 n/ W8 x5 M: G+ M L
; Split on newline (`n)9 V8 h9 n9 ]/ I2 u, n( M2 G
StringSplit, word_array, full_path, `n
. Q* N6 t2 N: G ; Take the first element from the array9 d, F# `/ i. f3 _) l! t
full_path = %word_array1%
: u ^7 Q! {3 j4 O) | ; strip to bare address: _8 V j2 C, G: _5 U! z0 d3 I
full_path := RegExReplace(full_path, “地址: “, “”), n/ L& w) T( x6 h: z
; Just in case – remove all carriage returns (`r): \/ o3 s( M( Z# D/ m4 D
StringReplace, full_path, full_path, `r, , all+ T' ~; T1 L7 U
IfInString full_path, \
( d7 Y* j$ }$ E% O* W {
. U" f- E- n- u8 s' y2 j Run, cmd /K cd /D “%full_path%”
7 g' i6 K5 q0 G( X }
8 U8 e% E+ t( ]6 k/ v | else0 [0 b. f2 P: w/ r5 E
{
1 O+ n @/ ?- C8 u/ C Run, cmd /K cd /D “C:\ ”3 @ X' `1 d1 C% `# G5 _* q
}
4 O1 y0 Q% T" v( I& o( r }; S" p2 J) l, w: ~
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
. ?' o* W; H$ ]& H0 S. ^( r 这段小代码肯能有两个你需要修改的地方7 m8 d" G/ s! v. U1 w8 |
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键6 v0 u _) A {$ }: V: ~
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
* L. _, [- q/ f" x/ M8 i& ~ |