此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。! U- H" {' _) n' X2 G" O
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
1 b0 Y7 Z( ?9 K2 v) b 方式一:, @5 ]0 b, h2 `% z
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
' S- ]! A6 d9 \6 B7 g' | 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和8 S E0 z& M9 e2 j
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。. p$ X$ Z& s. P" Z/ G9 A
方式二:
+ r7 Y6 A" ~, \3 p3 y+ l3 Q4 S2 E 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:+ W1 s3 [# h7 C2 h
SetTitleMatchMode RegEx
7 Q3 W/ X. |0 {/ k- W1 c+ Q return% B* W& Q( H% ^0 J. A; L' b
; Stuff to do when Windows Explorer is open6 ~" e2 N' G8 y$ B* t3 }
;
, y2 X. I8 d7 r! B1 S p9 p; q #IfWinActive ahk_class ExploreWClass|CabinetWClass
$ H3 N9 ]8 L( t ; open ‘cmd’ in the current directory
! w4 N& O8 ~( ~# Q$ R ;
- ?( d8 ]0 M1 x% W- _$ @$ M9 W #c::
4 X# A# \ b$ q( t) ]; F- U, V: U+ n- F; D OpenCmdInCurrent(): V1 c' c6 o2 L; e1 z0 } W- D
return
' n, p" ^4 Y. B4 c #IfWinActive: P( H+ J, A: H4 `' c: Y
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.' P) }7 ~, {2 {0 H2 [: w4 N
; Note: expecting to be run when the active window is Explorer.
& ]! ?, q3 D( Y/ M% I ;
) v. J& t8 K7 J7 k9 ]" J0 L5 x: p OpenCmdInCurrent()1 d8 b" C" b+ A. O; P4 k
{
5 F- Y& w8 D4 S1 i& {3 d ; This is required to get the full path of the file from the address bar; i; O, [! {' A: k
WinGetText, full_path, A/ {$ L9 Y$ o* U% B2 L, Y
; Split on newline (`n)
+ K9 S8 m9 e+ }# n/ n. m StringSplit, word_array, full_path, `n
G1 w: E" a% z; \ ; Take the first element from the array( K! o4 ?( M, ]0 J6 S* d
full_path = %word_array1%
5 t. {. y9 T# t: D ; strip to bare address
% K9 ?' T. l/ B W$ X/ F full_path := RegExReplace(full_path, “地址: “, “”)
H; D& k& P# |8 R! i- y! E ; Just in case – remove all carriage returns (`r)& j* v, e& x9 \1 ]
StringReplace, full_path, full_path, `r, , all6 Z! | s* P8 w) W$ N
IfInString full_path, \
; G9 I! R2 J8 h7 c" V8 H2 s {
+ Z3 n% B$ t1 v, j Run, cmd /K cd /D “%full_path%”
, l3 C7 W {" _6 O* j( d6 w }5 ?9 ?# o. x, M b, q
else# }- F% n1 c2 G* e( o3 M
{
6 {1 C; g8 m& x1 ^7 z Run, cmd /K cd /D “C:\ ”5 m) ~* e1 s) L" e5 s/ x5 ]0 W
}
; o1 h0 g( W; |6 V }" l( O9 {' L* C$ S$ i" F
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
* y" w$ v3 F: k1 }- y3 ]) u s 这段小代码肯能有两个你需要修改的地方
. {! u( R' Y4 [+ t. T 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
- ~9 n, L5 J4 \ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
4 _# {! c4 S6 t; |* I |