此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。+ a- n# n2 w- M5 t i p# R
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。( \3 R5 {) p( e S, r& I
方式一:
2 v. S- I- P4 L$ Y0 `/ r3 A 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
1 S4 f0 Y* z& V6 B5 D) B 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
1 m9 p% C8 u6 m9 G( C3 h$ n HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
) \ @2 Z+ C* Z0 @3 F$ c+ f 方式二: _7 f T8 Z5 m+ j0 g9 N
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
% P+ [$ D2 q) ^ SetTitleMatchMode RegEx8 _1 x" j: g5 \2 G
return
6 x& M! g" i1 l% p9 L3 K: }3 W# M& h ; Stuff to do when Windows Explorer is open7 z9 @1 i! M1 h- s# W4 u2 P
;
( j) X2 n J- T" H" i" n# b$ C #IfWinActive ahk_class ExploreWClass|CabinetWClass
) u. c7 n; T Q/ |. p0 k* H: v ; open ‘cmd’ in the current directory
* d$ j$ ?5 S4 Z+ o; @9 v ;/ e" Y5 x" d; T4 D# Q5 P7 w
#c::
7 }4 J6 c1 Y; d6 P OpenCmdInCurrent()
. m9 b* h' S5 `) o/ l$ r return
8 Y5 S8 H7 P% I8 o. g #IfWinActive
/ z" ]; t$ P4 a/ D( o1 [# C5 k4 P5 H ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.* f( g3 v% W3 A# Z/ z
; Note: expecting to be run when the active window is Explorer.2 c7 `) ~8 k% B1 a0 G0 R8 ~) j
;
, N5 s1 c/ P4 P# I/ X OpenCmdInCurrent()
' }# W" p) j$ G* ~ {6 A6 ]1 \! D; Z( ^
; This is required to get the full path of the file from the address bar* S3 o4 W; K; T( e* |) ]( N& U( e
WinGetText, full_path, A: r; g$ G6 W( z* i* ?' V
; Split on newline (`n)
, }! Z. m8 h1 C* S3 y' o, e StringSplit, word_array, full_path, `n: R& ^$ H: F3 A4 s
; Take the first element from the array
1 Q4 M" A3 K" i8 {0 y: f full_path = %word_array1%
: j: Z' d# s8 q( |* T ; strip to bare address
2 O7 }6 }' f: J+ }7 s) a1 y0 n" D2 o* ^ full_path := RegExReplace(full_path, “地址: “, “”)
' f( x X4 q- L' N+ } ; Just in case – remove all carriage returns (`r)- E9 v; t/ `3 _" |5 I: ^
StringReplace, full_path, full_path, `r, , all
- y/ i; E. U# ?, t" m IfInString full_path, \
* [! a+ A, W. F' C8 ~ {; c Q4 h0 a' H( B+ ~9 d: s% ^
Run, cmd /K cd /D “%full_path%”
$ o4 ^3 m8 B% D+ O }
! t' n% c7 k0 a1 V6 N3 p else9 M# Y: Q* O6 r0 r
{+ `! f4 F* t% J2 |/ B8 j9 G
Run, cmd /K cd /D “C:\ ”
( P! c+ I1 T( F" L/ A# h }* I E; q' c7 s" O
}. J' B8 _, n7 J' D0 G# O l$ M
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。0 N, W4 w$ X: {& q) T+ Y) G7 N; E
这段小代码肯能有两个你需要修改的地方: q% S0 N! l0 g7 z* m% c
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
- v( ]0 n; i1 u& f 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
, Z! z# `. _* Q* G- t4 N$ M |