此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
( U/ c, d, f8 ~* y5 t 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
H5 S; X; e$ e 方式一:
! q; z9 d, P% o( A3 n+ _- h 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
8 ~% z% J: W$ y3 D! ^/ [ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和6 C- P8 C9 z0 L* B; T
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
, ~1 V: T, y: O* Y# Y 方式二:" _# l+ ]" n+ ^6 c
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:! i4 J% X, ?* s* U' O, z
SetTitleMatchMode RegEx
! z7 }7 v% g4 c% V return; [ ^; E2 w. m% L( J- P8 s* B
; Stuff to do when Windows Explorer is open3 X7 N, `- L0 [% ^9 |8 Z
;/ T/ m: }5 P* k) A* h1 E
#IfWinActive ahk_class ExploreWClass|CabinetWClass
& }) [" C, o$ v ; open ‘cmd’ in the current directory6 q8 |( j+ K8 c3 w& n* ]
;: B% v1 R# s( y4 ?: Q( i. ?" B
#c::6 |5 l% N' Y* Z
OpenCmdInCurrent()# v- ^3 s. z( k4 r( f, C( _$ B
return; e3 U6 d' G! }/ j- r
#IfWinActive4 r% q: z, L) q1 H, L1 ~3 t- A
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
; w5 V( P' Q5 v, |3 i7 g ; Note: expecting to be run when the active window is Explorer.
4 A& z7 l# h) }, _( ~+ @ ;1 l, k- |8 f* g4 ~# f5 _
OpenCmdInCurrent()
- R+ t1 i4 x" P+ Y5 I {
! {. `) T# ~& R4 K! D* i ; This is required to get the full path of the file from the address bar
. p( R: S; r6 I T7 x4 d WinGetText, full_path, A1 |2 m2 }! _5 a- n! {
; Split on newline (`n)
. W. e3 g9 Y0 S T8 C$ N4 E' K StringSplit, word_array, full_path, `n
0 D5 b5 c/ V V" ~. G& O ; Take the first element from the array
1 T s( P& A$ O+ r, w) @ full_path = %word_array1%8 Z: u& n7 y* V3 M- O9 B5 Y7 d
; strip to bare address! i3 c2 u, ]% ^* F
full_path := RegExReplace(full_path, “地址: “, “”)
7 e. P! {: h$ r# S5 C ; Just in case – remove all carriage returns (`r)# `) T8 I n K" D' a
StringReplace, full_path, full_path, `r, , all, }5 j* G' V X( f' l- G) P& q. z
IfInString full_path, \* g' R* e; B! ~0 {
{! T$ K1 m" t8 u: \% m R
Run, cmd /K cd /D “%full_path%”
8 b9 I* R2 U3 A }
. J% N" L5 ]2 k4 A else+ b' h3 T) n' S% g- [* G2 Y
{
# S) o( r* ~! e( m% i5 E Run, cmd /K cd /D “C:\ ” o4 \3 E$ F4 | j: m$ A
}
! R# _1 E @2 Z9 P }
# g& O1 F) y' J$ s5 S9 g$ z' A/ @ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
, ^, }! L: }5 \ 这段小代码肯能有两个你需要修改的地方1 G. D: ~; p: G& R8 m& n. v$ @5 P
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键2 G1 f# \, W' G; }7 i$ x5 D0 E
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
7 |4 x4 I# T9 Q( u |