此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
" x; Y8 @5 d L& j1 ? 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
# K+ V' W- N$ O( s) d 方式一:7 E! C" G$ r" o1 Z: J3 ]8 D" s+ o* ]
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,* p1 l- `/ @9 ~# k' S/ k W( ~- g
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和& g, |; ~: i4 s. x+ n* U/ b
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
( D: Y; F& G( N0 ^ 方式二:! f5 [4 h3 I; j& P9 A$ E! q- y
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:( i' b( S, E5 Z' @
SetTitleMatchMode RegEx
5 c' ^* f& ~8 e: S+ m6 w return
* [! Q6 x0 H9 ?1 Z K( X ; Stuff to do when Windows Explorer is open2 |. Y4 A1 @3 ]$ q9 g8 j) y
;) T* G3 F, N# O# n# {
#IfWinActive ahk_class ExploreWClass|CabinetWClass
% ?" y9 Q0 O2 ^5 E6 H7 V0 \, y ; open ‘cmd’ in the current directory
& f& }+ {5 j1 J. X) T: N$ R) X ;
+ M& a2 w, D5 L n #c::
$ L0 T9 ]9 w' ^7 ~8 \( y OpenCmdInCurrent()
+ m1 i' X a4 _ return
& `) e4 S- Y8 e3 E( S$ T5 A #IfWinActive* L# e5 [- `; E
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.5 n; b+ S% B, ?* V
; Note: expecting to be run when the active window is Explorer.
3 s, S g+ ?" h0 F! l ;
' C; J. M* C4 e+ }0 j. x OpenCmdInCurrent()
7 c3 B# |5 o& I) @# P( {" {1 _ {' l9 X8 V( y6 G
; This is required to get the full path of the file from the address bar
9 w' | ?; g0 }' e1 o" \ WinGetText, full_path, A
M& s/ n7 S5 T& O% Z2 s ; Split on newline (`n)
4 D9 X; x5 s) c6 e2 ?+ y# A StringSplit, word_array, full_path, `n
; j0 q5 D. C* S& o' ^$ w; w3 } ; Take the first element from the array6 G' N1 F8 A' t/ ~
full_path = %word_array1%$ s% W) v" j2 X8 O, H) P
; strip to bare address- d0 `" Q+ {" q A$ U
full_path := RegExReplace(full_path, “地址: “, “”)
5 ?( o* q* P/ g" I3 o x ; Just in case – remove all carriage returns (`r)7 P& n: f7 X- T
StringReplace, full_path, full_path, `r, , all# Q- k3 k1 T4 \) P- V% Z
IfInString full_path, \
7 Q* I9 ]+ r3 S {
4 [ `8 z3 r b& R; b" N Run, cmd /K cd /D “%full_path%”1 i/ [* P6 c8 u; ?$ @
}3 n. N' M6 O. o6 l: @
else/ J9 K0 F0 p- P
{
8 t4 S9 z H6 O* Y1 c% f* q Run, cmd /K cd /D “C:\ ”2 e8 x! N+ B) t' ]) A9 g
}
6 Z: k* V9 G3 x- @9 x) T. l# s& ] }/ J @! N+ v! @( X' \- h
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
) `4 T1 F/ w3 s2 A+ C/ {6 x9 C! H 这段小代码肯能有两个你需要修改的地方
3 h e" }8 }, m1 \9 L 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
1 C$ d- I+ `% v- R' h' B 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
- n: _3 P. ?3 g3 s9 i/ k |