此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
. y8 {, Y8 ?5 d* a, a4 w* a 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
1 o1 R' y3 q4 U/ r4 J3 K) c" i 方式一:0 j% q+ e! L9 \& _4 C
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,; [9 s+ p& Y/ X+ J/ |( ]9 w
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
3 t$ q6 n* }, f$ |" A. Z HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
7 {! Y- G8 b0 L 方式二: t* I* H! U! p
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
$ k- @( b) s" j$ N SetTitleMatchMode RegEx
4 b6 N2 v! g6 m1 i. s return
7 x3 ]+ |" E* p% o- H ; Stuff to do when Windows Explorer is open
5 p, }1 o: E, A1 n- E3 L ;+ d; A. K& s: ~( U! u7 Y/ M
#IfWinActive ahk_class ExploreWClass|CabinetWClass
, e6 @/ r: q% v# l4 ? ; open ‘cmd’ in the current directory1 k5 A) y! d4 v$ e6 Z& ~& N. D, _* f
;
, a6 d* H( o0 @1 W9 r P# ^4 O #c::! f, h* G$ \8 V# A6 F) I
OpenCmdInCurrent()% j. b% b$ D- ~
return0 o) \# H* u0 N5 M
#IfWinActive
Y) x9 T( p: c7 ~ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.# [; r. P9 [; U1 O' @4 {
; Note: expecting to be run when the active window is Explorer.1 [" G" m% F Z8 y2 P/ \( m' ?: B5 w
;
8 M* ]/ ~* I2 P. V' @. H/ | OpenCmdInCurrent()+ E" h4 U' j/ W9 L3 Y
{
9 T8 B* Q+ E H ; This is required to get the full path of the file from the address bar3 M I' S5 I* g; u2 O) X3 J
WinGetText, full_path, A. S% {8 Q, h2 `4 A" C% L9 U
; Split on newline (`n); K. Z3 p8 L( Z8 t) t6 j% I
StringSplit, word_array, full_path, `n
: @7 G9 N# s9 u0 x8 E# T4 B! g/ N ; Take the first element from the array$ s4 @1 o" g- E! h. R; ]; D8 r v
full_path = %word_array1%# j$ B7 ^ j& x3 F
; strip to bare address
4 A' g b, | ? full_path := RegExReplace(full_path, “地址: “, “”)
: P1 s+ g; A4 a$ _7 q+ g ; Just in case – remove all carriage returns (`r)( _& {" t G* B$ b& Y, S
StringReplace, full_path, full_path, `r, , all& |( k' S+ ~. g$ w; D
IfInString full_path, \
: A. e- K8 R! A+ R' g {
2 Q+ E3 A. @+ c' m0 J0 x' F1 U Run, cmd /K cd /D “%full_path%”
2 Z# Y% h- C: N# P }
: N7 q! g6 \ [ y; n4 B- U7 ` else, T( x4 C. m' H3 x# k0 U8 r7 b
{; I& X& X* H, Q
Run, cmd /K cd /D “C:\ ”' p, S* F+ Z! N3 g0 F/ m' h {
}4 y2 M( B$ a' w; q3 S
}
0 j1 c; q' a+ T0 M! m$ d2 F( K 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
$ S) W# A5 X; S# k! [6 a$ b5 r 这段小代码肯能有两个你需要修改的地方
$ R7 G, ~& n1 Z _; i/ l 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键. l z( i/ `3 W9 H/ ]
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
2 ^& u6 ~: t; I! x1 f% h/ a2 N7 Y# Q |