此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。) b9 `$ @! I! m, t6 e
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
! q: O5 E9 O" @7 W 方式一:9 G0 j! A/ p6 B+ p# U7 U
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
$ e" ~/ U! A8 X4 [8 M. J 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和+ b' s7 o8 _/ u
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
2 N7 `" i' P4 b* [0 J1 ] d 方式二:
' D1 ?% x' s; h1 L 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
0 ?$ e3 q: C! B SetTitleMatchMode RegEx
/ j+ ^/ G) k, k) I return# B3 f) I. U2 {* u" ^
; Stuff to do when Windows Explorer is open: d- q+ w1 v9 R" Z2 @/ B& ?. ]
;- ~4 g8 X4 _+ d9 C$ B/ ^ t
#IfWinActive ahk_class ExploreWClass|CabinetWClass) j: c% {& [ e- J: P+ \
; open ‘cmd’ in the current directory
7 Y1 A6 p d* r6 t) W) E4 I ;& y0 g# G! z1 G0 l. G1 i
#c::) z# e5 a+ e! A% s& [6 M; M: N
OpenCmdInCurrent()
; [0 o$ Q9 `; T4 h return
; U: J4 ^5 u+ l8 D+ X #IfWinActive7 _) t& J; v) Z" O% ^8 R+ M0 s" [
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
+ w. Z! M6 t; {8 f; w& Y$ C ; Note: expecting to be run when the active window is Explorer.
: i6 V8 D7 f4 Z; a2 w2 U ;
: h5 |; j* f) W: Q- {% \( I OpenCmdInCurrent()
/ L/ q: r1 ~$ |8 n5 x# G {" H; u h1 S* W+ ]% L ?0 i
; This is required to get the full path of the file from the address bar
4 ]$ L2 A' }. P" Z, M5 H WinGetText, full_path, A4 @ V. r3 |2 u% i
; Split on newline (`n)+ ?% E, [: _, {9 l; X$ B, J# d, m
StringSplit, word_array, full_path, `n
; W& }( e! O. ] ; Take the first element from the array
, u* n- M2 |! w+ Y full_path = %word_array1%& n9 k& k& b: k) H
; strip to bare address, |( t1 @) j- E* U
full_path := RegExReplace(full_path, “地址: “, “”)
0 q+ X; s( h3 O ; Just in case – remove all carriage returns (`r)" i7 a' k# \" q' m, r/ n2 V9 u) H
StringReplace, full_path, full_path, `r, , all, Q2 J3 d5 k# g5 K7 ^
IfInString full_path, \
6 e: i1 v2 U- R- | {
; Z9 v! \# r6 r2 H* I Run, cmd /K cd /D “%full_path%”
2 K }, B+ s g c }, a2 l7 w. p% { W( R
else' V$ }3 D9 I( j1 C: N: S1 n9 J0 Y
{
. w4 v# v# h* \4 A Run, cmd /K cd /D “C:\ ”1 B) c- C( N$ m9 ]9 C0 V( Y
}
% a. C Q: m1 h6 X2 N/ S$ Y }
' \6 q4 A: h: Q& U9 X 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。3 y2 a, y+ |' F3 L C
这段小代码肯能有两个你需要修改的地方 t: {5 |8 v+ b" \
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
: k- N& I/ x1 K- ]4 J! i: n8 g) R 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
7 Z+ r( p( k( _ |4 C a |