此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。# X; f, I0 m1 ^
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
8 s! E: l5 Z- P: E, ? 方式一:" B$ z; P5 @, r s" R9 m6 p
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,8 l9 D& p; m9 |
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和$ e: [8 Z7 C* e
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
$ \4 b( X" J% s6 [* C# O b 方式二:5 X) H0 Q4 T: n `
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
/ m, l1 U% D" e O% h SetTitleMatchMode RegEx
. u3 b/ W7 G% x return
& B, k8 |; c8 J2 l0 A0 v ; Stuff to do when Windows Explorer is open
' }4 u- w) {/ ~' C4 l ;
" F/ Q3 i/ q* N9 y& k- R #IfWinActive ahk_class ExploreWClass|CabinetWClass
' W2 s$ w# M- a4 B ; open ‘cmd’ in the current directory: S% m- f7 S% U* M
;
! l$ p0 V- i' ~, m3 _ #c::
# r" A4 x9 Q' D- s OpenCmdInCurrent()
* | ]) b. u0 {! W6 U {0 K return* G0 m. i6 m$ s4 V! h8 E
#IfWinActive
- B1 f! h% n5 R6 g ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.0 J- {- ^# N, h) p
; Note: expecting to be run when the active window is Explorer.8 G, S s2 i& S& I
;5 v6 B- ^( ~# k' _
OpenCmdInCurrent()
- P( i% g. X( C4 h5 e$ Z {' L8 u8 ~; I0 |& D2 W* U7 f6 c- m
; This is required to get the full path of the file from the address bar% A/ O# Q. T7 l
WinGetText, full_path, A
: D0 p4 z; o" g' D0 ? ; Split on newline (`n)
: j+ q7 s Q) s5 U. [" E) c StringSplit, word_array, full_path, `n7 N" ^4 I! i% W% Z
; Take the first element from the array3 \; ]' T; O* I5 P: K$ ^$ |" @
full_path = %word_array1%
, m3 ?9 B- B w( _ ; strip to bare address9 a2 w3 p3 {. ~7 [0 w" [& U
full_path := RegExReplace(full_path, “地址: “, “”)0 p, _' C, H. u1 M6 f7 s
; Just in case – remove all carriage returns (`r). a/ @$ V/ y* w; I( P7 y2 M
StringReplace, full_path, full_path, `r, , all$ d! n8 I- P0 B3 g# O, N
IfInString full_path, \0 R! _2 X V6 L9 m
{" ^- c- A) Z) m! i8 A/ z
Run, cmd /K cd /D “%full_path%”
. N4 t8 q- u5 N% B3 v! C, q$ G }& t7 x. j% ^" S/ I
else
, y% ]6 C+ \, i1 o: m9 W {
& h3 q( Q7 f1 }2 E/ U+ Q; }+ y Run, cmd /K cd /D “C:\ ”
2 R6 t* g. B& m }* T- ]9 @8 F9 p; c) P/ I9 a4 C6 t
} j: N" H9 C2 Z/ j
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。# z& t: m5 _( c# k4 C' _
这段小代码肯能有两个你需要修改的地方; U7 o) E3 r6 o1 T5 \# l- P
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键( b$ |' O* M/ E9 E
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
: b# h9 H$ c; T& \) Z$ } |