此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。* Q, v# w# s& j9 \9 ^- J
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
4 g: U- w$ S% P. O g 方式一:1 f" F& s& P+ [ M$ K
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
7 f) m9 e2 {' B5 h$ D+ m" ^ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和1 x7 w! D$ h7 b( Z$ W
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。& J/ {8 {; Z0 h! }. W3 T
方式二:
3 ?7 J; \5 v$ P( K! h k 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:% ^# [3 \* k5 |' T. U, k! O
SetTitleMatchMode RegEx( D8 X% U+ N* Q. [# D B( K0 b
return0 t% Z J e* z9 O' e7 U8 P
; Stuff to do when Windows Explorer is open
6 s$ B; m Z. P( ]8 ]/ X' y ;' z' f$ u3 ]) N* f
#IfWinActive ahk_class ExploreWClass|CabinetWClass
: N7 S' t/ s" ` ; open ‘cmd’ in the current directory$ L- Z1 A3 e+ K3 O) P' ? ^9 o
;, F4 k, |6 q) i" O0 r- a2 \
#c::
9 K, L- s5 R$ a! Z" R! S8 P OpenCmdInCurrent(), h* X" ]7 L2 z. f/ k4 u! M
return; v7 r, Y! Y* x; d4 K
#IfWinActive
2 b( m1 E8 }+ h1 X ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
( h1 S! S( _7 V# e+ u ; Note: expecting to be run when the active window is Explorer.
: ~7 s3 K4 p. {' ]3 Y6 z1 ~ ;
, z% y8 s: O4 ~5 b4 i OpenCmdInCurrent()
' s9 r2 A0 J0 p3 H2 s5 n& I {
/ I- V- v1 b$ t! G7 P# c ; This is required to get the full path of the file from the address bar
, s, [1 X( N" J# v- i6 _ WinGetText, full_path, A' @/ N5 [1 a J% e3 R9 ^
; Split on newline (`n)
3 D! F$ G$ J3 r5 C: V. E* h3 _ StringSplit, word_array, full_path, `n( y5 |$ n. v. Z4 X
; Take the first element from the array' U h8 @" H0 h. f3 ]$ c; k
full_path = %word_array1%; ^, z4 X5 x) k1 D) `9 _
; strip to bare address( r& [9 w: T+ `4 ^. `: U/ q
full_path := RegExReplace(full_path, “地址: “, “”)
. q5 m2 @5 @- ~4 t7 b ; Just in case – remove all carriage returns (`r)
$ _6 U: z. t- Q$ M, H7 l StringReplace, full_path, full_path, `r, , all
% V+ Y. R5 j; v IfInString full_path, \
5 a7 u7 Y& b' h% E0 ]1 G {
# k% p/ k8 t- O& |! O0 o Run, cmd /K cd /D “%full_path%”5 q+ _$ _; u- U# v8 Q
}
% t8 d3 w# t- z: x else& ~" z2 ~* i- ^5 q
{- H% C) g$ |$ a5 A! x
Run, cmd /K cd /D “C:\ ”3 y0 r! {. n! n! C5 ~8 u& [+ Y' B3 ^4 V
}) B- b' d* s5 N
}
3 i0 F, w: Q X" {/ L( v# q+ V 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。! @3 D3 H$ ^+ C& C) K
这段小代码肯能有两个你需要修改的地方
# E' D3 t) I( z/ t7 w0 |% [! a 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
/ o4 @2 P R, x7 m% N" L- w 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “ A) G/ Z' j/ l1 N
|