此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。2 B" ~; u% h; w- G" [
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。+ a! X5 N( s' W* I5 e1 Y% A/ [! J0 G
方式一:; D; @9 W8 ^, b% L- q
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,; s$ e% \6 y6 i x, m
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
; I: p! O' n4 R8 h# k, I HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
% g' H2 q# t' h8 K& e4 M 方式二:
( r1 Z. r3 P7 P) d+ m4 f3 G) I 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
2 X6 J3 B/ W) ? SetTitleMatchMode RegEx
( _* J8 a ~# L, A return
7 {1 z& ~2 p6 C) p, A ; Stuff to do when Windows Explorer is open- o0 D" h. u4 j% s3 H) j9 o! Z! H
;, o+ l- B1 M" J: A: \! h. K* @
#IfWinActive ahk_class ExploreWClass|CabinetWClass
/ E; d9 X5 h- t9 o ; open ‘cmd’ in the current directory; X+ o/ s9 v3 g" P
;
% o$ H6 ~7 R( ]4 {9 S #c::
; {, L9 D# q g% | {4 q$ |1 J5 p OpenCmdInCurrent()
- d8 X$ ?% q0 M5 D- t8 H5 | return
# f; \: G5 f# F8 X" R) ]) p7 E T7 q #IfWinActive+ x) w0 R& t3 C) Z( M3 @0 S$ Z
; Opens the command shell ‘cmd’ in the directory browsed in Explorer. V d# U; F( w
; Note: expecting to be run when the active window is Explorer.
+ v/ H, z G# D, h/ f ;' D7 v5 V6 K2 @8 U& }; I0 B7 b
OpenCmdInCurrent()
+ x Y7 Y1 ?6 X# o6 R$ a+ s- }" S {' h1 ^: P; R# t! W% ^
; This is required to get the full path of the file from the address bar
: }; W. L" s T7 b, K% H2 |: f- O1 L WinGetText, full_path, A
. s9 L( _( Q2 N2 L6 y ; Split on newline (`n)$ b& _. a* }/ ] M6 V0 s8 |
StringSplit, word_array, full_path, `n
0 i5 ]- K# x W, y ; Take the first element from the array
5 l ^5 Z; N! j2 z) l& \( m full_path = %word_array1%
" _+ W. X7 w: N. S) e8 { ; strip to bare address
. c3 n, t- ^% I6 e/ m3 A1 m. S full_path := RegExReplace(full_path, “地址: “, “”)% @( w' d; b9 o/ |
; Just in case – remove all carriage returns (`r); p8 e% Q8 d% _: ~$ i: _6 t+ h
StringReplace, full_path, full_path, `r, , all5 z* `) V/ T0 ~7 ]& K' X3 z+ g
IfInString full_path, \
# _( j9 L1 J/ `; L" ^ {
5 Y* f6 _4 a3 C0 _" J Run, cmd /K cd /D “%full_path%”1 p) ?1 D4 G9 w- i
}
* h# O0 [5 j( B3 E' Y% t2 U4 a, B else- S3 `2 p# o5 \, X6 ^2 o
{- c9 p7 C; {8 Y& g, V
Run, cmd /K cd /D “C:\ ”
: v: o5 P o3 J, x4 V t0 h" } }
0 a2 H R+ G1 n/ w }- n) I; Z7 Y% w# U
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。9 Q; G# i) h2 {6 P" Y1 [
这段小代码肯能有两个你需要修改的地方
( d/ U& z$ x3 t c7 j. W4 Z6 A8 W 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
9 ]) m2 J+ k# A% C( Q 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
. t, t7 F8 }7 g/ }$ m7 H2 K |