此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。/ [* K9 G& F" f( U) e
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
; s. {% u4 e: r9 z( N 方式一:% ?8 k! ] i" B! n
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
5 f$ Z( x" |; V 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
# ^% M, Y+ Z& R3 D9 s- C. c HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。: Z" G, Y: \; C3 q
方式二:
" O0 ~" j. J0 N* V! Y. _ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:( m' i# S0 Z& m/ I- U% I9 W
SetTitleMatchMode RegEx( I9 E3 E* P. E* G% o/ l
return
1 p; u+ p6 y( T ; Stuff to do when Windows Explorer is open3 P6 U( ^7 {/ j0 q7 ~ W5 ~
;* @' v2 s/ n) n. y+ f) O* p0 t5 c
#IfWinActive ahk_class ExploreWClass|CabinetWClass
" D! S- T7 O. ?2 u) E6 ] ; open ‘cmd’ in the current directory: P" W% o- Y2 [# K
;$ I- F- |5 ?0 m2 S: v
#c::" y/ K; n" K3 K7 n* p+ K& [
OpenCmdInCurrent()
0 S/ \4 W9 v( ]# p& ?$ i return. f$ |; u" }% z. r# j
#IfWinActive8 J$ P, r7 i0 ]
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
+ f7 N0 z" ^ d8 {' C& [# B ; Note: expecting to be run when the active window is Explorer. a) p# d% K1 L6 E8 S
;
$ ]4 j" U4 X; R" ~: p, K OpenCmdInCurrent()7 f) g# A5 W- D* l [
{
, Z$ k2 D8 D' \4 ~) P6 b ; This is required to get the full path of the file from the address bar1 y6 ^" W9 n' H2 ?6 t: \% W& e
WinGetText, full_path, A
" K& A) W6 g9 E0 O+ Z$ U# ~ ; Split on newline (`n)6 S+ g2 ?5 J' f
StringSplit, word_array, full_path, `n; g% L: h' P! S8 v& q) p
; Take the first element from the array5 H3 X* k+ _. p% C1 f
full_path = %word_array1%
% Z* P2 q2 H8 ~9 Z% r2 j% B ; strip to bare address5 K* w' J+ e# k- t+ y
full_path := RegExReplace(full_path, “地址: “, “”)$ C0 A! i$ o' z+ g
; Just in case – remove all carriage returns (`r)8 f& s& {) O2 O' j5 C
StringReplace, full_path, full_path, `r, , all
" N3 t4 x# ^, G1 y' R s2 T. o IfInString full_path, \
! i) e* l# k3 k4 b {
/ s9 K" Y! q( g7 A! ^ Run, cmd /K cd /D “%full_path%”
`# \* s; u+ j6 \ } d/ [ h4 M/ Q5 }2 r1 X
else$ E3 s' }! F: ?! F+ N; f9 H
{
* s9 d, K0 K1 ` Y/ d0 n' i Run, cmd /K cd /D “C:\ ”7 x i) ~' b" A' `: Y5 c
}7 l& c6 c/ O+ p( j( z) W
}8 U s8 C; z' J4 a7 F
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
+ A3 P) P$ |/ I" B3 F. C 这段小代码肯能有两个你需要修改的地方
" I/ N& M3 x* z; c& t" P 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
" M& A" T7 C9 D, T. A" t, T5 u 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
0 O- J& {" c3 H+ P- t |