此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。 B" B' B8 t5 a" W
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
' T8 A8 O8 _% a" \. Z- e. z 方式一:
# v: E5 r* F& K- n' r 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
* G6 o. Q' u2 T; o. W9 w 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和8 r/ e {4 ?4 b" n& A; D4 y
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
1 x2 ^6 @9 H" x1 U 方式二:1 c& [' ?! ]# A
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
% H& X! O7 j" n1 a; [* G! O+ ` SetTitleMatchMode RegEx
# U) n2 @, Y6 y, V0 T return
/ b4 M' F" y4 R8 F1 z& K3 Z ; Stuff to do when Windows Explorer is open5 f4 u% O8 v& o
;
3 d" q: T0 {& G1 {( v: Z# T #IfWinActive ahk_class ExploreWClass|CabinetWClass0 f2 S; L+ G6 A
; open ‘cmd’ in the current directory4 Q e# D$ w% m( i# _. m
;& N/ |3 Z2 _3 e/ `: `: O
#c::- |- v/ h c+ V6 k* Q9 |( g
OpenCmdInCurrent()" s* x9 u2 q3 |$ Z0 ^+ p; t2 h0 V
return! r9 l; I: ?+ m% z% V# q2 k
#IfWinActive9 u( }( p& h8 S
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
: E, \. b8 }3 ?% `5 h ; Note: expecting to be run when the active window is Explorer.* l6 I8 t. a# G) Y' p7 u5 l- ]
;
& ~' D% R/ d; m( H7 K3 N% } OpenCmdInCurrent()$ B3 X) P7 Z8 W0 c, N
{. r4 W# ~+ p" J4 h2 V; z( Z: ^! n
; This is required to get the full path of the file from the address bar2 V* ]& g9 q- M& D% Q
WinGetText, full_path, A. l' A4 X3 I- S7 C( b3 e
; Split on newline (`n)
. f3 U8 O3 A* U2 q$ }- x; c StringSplit, word_array, full_path, `n
8 f+ J( e T4 ?5 h( G, v ; Take the first element from the array
2 K4 ]2 {- B% l1 g7 F full_path = %word_array1%
+ V% ^, ]! P6 d! v$ z/ G ; strip to bare address
2 v" Y. p: a3 a- [ full_path := RegExReplace(full_path, “地址: “, “”)
) I/ @$ A/ ~# N" O J3 j! J+ O ; Just in case – remove all carriage returns (`r)+ _3 _7 O- ?2 R! m8 b" Z) c
StringReplace, full_path, full_path, `r, , all
; h, @" O/ S! B IfInString full_path, \
2 k7 I( u: X6 m$ C {
8 \. ]: C( C; e Run, cmd /K cd /D “%full_path%”' d1 g' U! `- O3 G
}5 ]; x% E2 P8 i7 E0 W
else5 J" p4 g& p! u% a
{& u, I9 E4 |4 ^; R/ n
Run, cmd /K cd /D “C:\ ”
- Z+ m0 @( J& t7 V }/ X$ s7 Q/ j" k3 E- U& `0 T8 r
} k/ U5 L+ o1 d; f. j
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。* E" A4 L6 v' G7 J$ C. F+ T8 y+ u
这段小代码肯能有两个你需要修改的地方
5 Q6 D5 u, B/ w# `* j 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
- C q5 i! y. Q" ~ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “$ N+ O0 _$ R" |2 n+ r8 D
|