此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。# A! w6 i0 Y% f+ G ~
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
M( s' I2 k. S: }3 [# ` 方式一:6 _; q) R: _% P9 B9 `2 |/ \
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
. U& Z* C3 W; c% C. x$ d! L, Q 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
1 X9 w4 ~4 B2 F3 r) j+ V$ D. Q8 X HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
6 r& h& ]# u2 ^. u 方式二:; Q6 D1 d6 Y1 W5 z4 X' ]
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:- s8 f: S" z) u# S8 L% c! w, w8 b
SetTitleMatchMode RegEx
! s: j5 q5 n3 [" ]6 _* P* t1 I" | return
3 _3 `6 p' Z$ }, A+ J8 Z ; Stuff to do when Windows Explorer is open
2 y. @* i/ q" T3 { ;
3 H+ [9 s: ]/ a8 m! |+ H #IfWinActive ahk_class ExploreWClass|CabinetWClass* V$ Y% P# S Z D3 a7 G$ c
; open ‘cmd’ in the current directory
* P& V3 U6 j6 o ;
- C' B X/ W1 D' Q #c::
: ?+ Z' |( h% W5 |$ e OpenCmdInCurrent()/ D: t0 o( k! N1 e8 A1 a; m& |
return; m. N2 o( {1 h; B. B
#IfWinActive
9 Q q( d; g$ x: x- P ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
' }& L @5 C" T! ? ; Note: expecting to be run when the active window is Explorer.1 ?8 [* Y) a5 o- U+ ~
; L! C. p9 b, r
OpenCmdInCurrent()
' K" e3 B; I. _4 u {
6 d' b& A6 K0 c ; This is required to get the full path of the file from the address bar! H- e' g7 e+ B/ F
WinGetText, full_path, A
/ o3 l* t F; ~/ j$ u ; Split on newline (`n)
* b# L! ]1 _7 x& A$ s* X, R StringSplit, word_array, full_path, `n
5 g5 e. u: J4 X1 i" h$ A ; Take the first element from the array" B8 I2 x7 I. j( J- U0 j
full_path = %word_array1%
0 A' q# B. B( |6 ^; u ; strip to bare address
+ V( s. ~ L* q& c full_path := RegExReplace(full_path, “地址: “, “”)- F3 W8 ^& q r$ ?; ~4 p. x. r( _
; Just in case – remove all carriage returns (`r)2 {8 g/ `, m$ G/ I( d" K+ R- L
StringReplace, full_path, full_path, `r, , all# B9 p$ ?* Z- |# A
IfInString full_path, \; z3 t. q- `6 r% Y. s3 K) \
{1 H: j& s3 t$ ?" ~
Run, cmd /K cd /D “%full_path%”5 V9 Z/ j5 B8 R0 Q' _
}+ A- I" T9 t+ H d
else
1 u( T4 Y; x _* H" U, ]7 _* v; ^; N {
6 y! L& X- \9 b* @" c& y. I! ~+ i Run, cmd /K cd /D “C:\ ”7 P0 ~- X9 H# g6 d
}
% E, k" }* v7 { X4 ^1 ^ }1 S# N9 s I! q9 h6 X ^: J) D* h
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
! _" E' T* E2 F L6 ^ 这段小代码肯能有两个你需要修改的地方) k% X" D. I% v5 G- W9 @
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键& R* t; |% L, ?0 j5 Q8 _
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
5 O9 h8 b0 c3 z- G3 [1 a% O |