此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
4 O2 T4 Q1 l4 n0 [# H' ] 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
* _. v7 {8 }: Z" O& E' u d% G 方式一:; ~3 o2 q, s; Q4 Y
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,* l+ y$ C% [% l/ W/ ^/ Y2 n
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
/ d8 O+ _+ A5 t7 `3 j8 J1 V5 c HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
3 ]: I& P5 P9 ^/ A 方式二:
5 }& m0 t6 B. C, a* s+ O* k 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
- c+ H" B& m/ N3 d, D0 q SetTitleMatchMode RegEx2 j1 p" _7 x5 B4 H; q3 O: l+ j
return/ v* {/ s% x, B6 r2 Y0 K; C- T
; Stuff to do when Windows Explorer is open8 J; s' D5 ?5 v X7 Y) M( |+ j$ X
;
2 d% j- b$ X" M5 o9 l #IfWinActive ahk_class ExploreWClass|CabinetWClass
- d0 Z+ P$ i1 I4 q* a: Z% B% B ; open ‘cmd’ in the current directory1 H1 k1 N1 ]/ m p: u& A: k5 G
;
% R8 M2 k5 f: l0 f; r7 X6 g #c::8 C) L7 ?( G" H/ B% W9 m; f
OpenCmdInCurrent()
% i H% T0 T: X. s2 X1 w return
7 G9 M) ?! r, g5 v4 y #IfWinActive
# Z1 e, g" U( c. |, V- T5 l ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
. l& p4 y* w4 B! q4 q* A# { ; Note: expecting to be run when the active window is Explorer.
0 f, r7 l4 k( H( [6 a/ \6 m+ b+ p ;5 p# h0 R) Z, {5 z; K% O
OpenCmdInCurrent()" q+ q! i& Q' a m# P% a' ]& _
{2 I; V3 i2 {- H5 \& t
; This is required to get the full path of the file from the address bar
8 a; T# c5 Z( G4 F WinGetText, full_path, A
) t, Y! b7 g) K* ]8 z ; Split on newline (`n)$ f% v0 l. r3 R0 d, b# Z
StringSplit, word_array, full_path, `n( F! S/ v3 u& I
; Take the first element from the array$ X9 H% C* y+ Q; s$ b- d3 W+ M1 j
full_path = %word_array1%# U0 C* e, d# p9 f$ d: S
; strip to bare address0 x: T' [+ e0 c8 T* a
full_path := RegExReplace(full_path, “地址: “, “”): g! f; f) U( O' i! J
; Just in case – remove all carriage returns (`r)( }7 F3 T/ ~2 l4 i' f6 K- F
StringReplace, full_path, full_path, `r, , all
* q! u' B# h' Z/ N* Y$ O7 F IfInString full_path, \
5 @% c3 N/ m' l& q {7 Z* w1 K. O# N0 X( Q% p
Run, cmd /K cd /D “%full_path%”
. W& u% H1 C+ a8 z# S }5 |- {0 h% ^" T) u" a
else& X; H9 B2 u) \8 I2 c* r- v
{
( _2 r, m3 v( g( u L Run, cmd /K cd /D “C:\ ”, C9 w) P1 V$ u% P+ J4 _7 l
}2 Z. g" k8 }( c9 J O" q% ?
}
& K/ u) }: {, u- D 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
* t4 N- X( O; Y 这段小代码肯能有两个你需要修改的地方2 T) c& Y& Q$ H5 N. M
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键5 d- y6 ~ I, V0 K8 L) f
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “1 b* O( J$ O9 P6 b2 Q7 ~
|