此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。3 S5 p8 h; s7 f: F
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。; G* H& Z( t$ |' H
方式一:
( Q. ]& e. a2 _, a 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
( H$ z2 X0 c* Q/ a; B" Y 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
8 E: e! E( V% y( |$ }" O HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
' ~1 }' [/ c( d% A5 x& F( e4 Z 方式二:
; ]+ [/ S. t: g+ X$ N7 {9 \ E 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:% C! T% A; P `5 T: L+ R6 t& L
SetTitleMatchMode RegEx4 l% \; k+ U$ R0 I
return
$ c- N- y9 U$ k% W ; Stuff to do when Windows Explorer is open+ g2 W2 p: P( z) Y3 N2 u
;9 e5 v$ F3 Z6 U
#IfWinActive ahk_class ExploreWClass|CabinetWClass
! h/ C' v; _* A2 Q ; open ‘cmd’ in the current directory
# U7 v( j3 l p0 ~ ;
: z5 g) ^- i- P' { #c::
: k! M: E+ m- L& w OpenCmdInCurrent()
5 u5 |: T% a; Y A U( Q6 U: I2 L return7 L" D) @8 d c$ C
#IfWinActive
' K* ?# H% [2 M9 |6 R8 p' x3 K ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.: X: K9 ^8 Z) B4 g2 p
; Note: expecting to be run when the active window is Explorer.# Q3 i, v- r9 @: |+ ]
;7 }+ I0 ~& a* ]9 U
OpenCmdInCurrent()& ?9 ~* C; N4 S; N0 R! g
{% U: Y6 R* p: o7 N, S+ Y4 A
; This is required to get the full path of the file from the address bar
! G* `+ `- i3 B( O WinGetText, full_path, A3 m1 y' [) v' l/ n$ Y" W
; Split on newline (`n)8 ~, F+ M% T2 P) J" f8 J0 z: r
StringSplit, word_array, full_path, `n
6 ~6 A! s$ d; c6 {; Y) O' r, ` ; Take the first element from the array+ a% Q" g A- d6 n
full_path = %word_array1%
: Y! Q, h. m: I! `, h1 w; A6 f2 G( T& p ; strip to bare address
! `! {: x$ n2 g/ Z& I3 @ full_path := RegExReplace(full_path, “地址: “, “”)* w5 t8 n' `9 B P; j$ K
; Just in case – remove all carriage returns (`r)
5 y ?( E; H9 Q/ t* g4 a# W! Y StringReplace, full_path, full_path, `r, , all. |) F. d& R) e: X/ S" e+ r5 U. d, Y
IfInString full_path, \0 f. w1 D5 G$ j% p" e
{$ Y: g" m) v7 _& T7 I% |$ w9 l4 A1 T
Run, cmd /K cd /D “%full_path%”
+ e, ~: }, B$ N7 R9 w$ M6 y/ p }; \) T0 m" D# {+ E
else) f x& \( b4 }
{2 o9 A! Q# P6 [4 `
Run, cmd /K cd /D “C:\ ”6 p2 {! O6 P; U( n
}5 r0 r+ E: f2 M; a5 z( U7 H' a3 B
}8 I% J8 Z/ i V4 r; n, w
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
, M5 H& {# x& x 这段小代码肯能有两个你需要修改的地方1 ~5 L6 f3 H" E* P, f+ U
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键7 V+ V" P, B" F. l: y) q
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
% w | b- P( n% M$ J0 U Y& [1 b |