此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。& S+ y7 G2 t) y3 p. J$ J) c/ _
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
8 H: A' t$ D6 ~ 方式一:
$ W5 {6 H# a2 I1 Y" j2 j0 g 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,! \- `+ ~9 o |4 v! S9 H
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
! D) x6 a6 j U- F0 G# I HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
+ K4 Y# U0 c4 X. f$ _" I( _4 E 方式二:
}- V# @5 } k+ ^4 i 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:" o$ C, g! `) E0 g, p
SetTitleMatchMode RegEx
- S1 C% b( s1 ?$ T return' B, h; ]4 V; _9 z) T
; Stuff to do when Windows Explorer is open
. s. x) U* T% F# R5 n( ?) B ;
* F* R8 W) {* J9 t) O" b+ g: I #IfWinActive ahk_class ExploreWClass|CabinetWClass
5 z) J' ~* x$ X A! m ; open ‘cmd’ in the current directory
8 y/ X$ m" F* T& ` ;0 M. w& }) I- L! N e
#c::
5 A# h1 B. u. U OpenCmdInCurrent()$ x; S/ Y8 u* l) w, S/ L1 l( [
return
, X1 Y' f5 F' o4 i* X1 o* f #IfWinActive
. t1 k P! B3 Q# h ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
# M4 p4 x9 W% c$ F5 `+ H ; Note: expecting to be run when the active window is Explorer.
' X# g. \1 ]5 X/ O& t ;3 a) \, g6 f, ^! M
OpenCmdInCurrent()7 L% d' o+ ~! U' a% g! d
{% m# |. ~5 B6 f' C# X S5 R
; This is required to get the full path of the file from the address bar; f, q+ t' q7 o- \: \
WinGetText, full_path, A- t Z+ O8 ~% j5 s, W
; Split on newline (`n)% J4 k% }, m0 x7 g; w
StringSplit, word_array, full_path, `n
8 \* z! y. b& Y1 i# ` ; Take the first element from the array/ [. R4 h; {0 X- I; Z$ Z- z
full_path = %word_array1%
/ S h% i( q, i$ C ; strip to bare address
: U% C. |5 n" v3 S0 v5 O8 z full_path := RegExReplace(full_path, “地址: “, “”)/ k/ J0 T6 U, D+ l. V
; Just in case – remove all carriage returns (`r)% ]0 \/ ]1 i( E/ S+ V$ R6 Q$ C2 j7 H
StringReplace, full_path, full_path, `r, , all6 M9 u, S8 x% i5 r
IfInString full_path, \
! s5 E/ m9 i, B; ` o5 M# {/ z: ?4 g {
8 Z5 r% s# ?( r Run, cmd /K cd /D “%full_path%”
5 c2 F2 P: v: T5 q1 R/ @$ T. p& Y }
; w0 y/ l* h) r* V/ c6 D else
M2 r; M& e+ L0 _% M {1 `6 l- N9 u6 S* s7 s
Run, cmd /K cd /D “C:\ ”
2 M: `4 }! P8 r( R, e8 r8 X& p }
' f3 |8 n4 i; c. }: \ }( G. E; o9 `9 Z
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
& r5 V/ [+ D" F$ w 这段小代码肯能有两个你需要修改的地方 e* x; W y7 l N g) c
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键5 e& L$ i! P7 X/ S5 v) [
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
1 Y& c+ n/ F- ]( r' Y4 E1 W |