此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
: ^/ q( ?5 s7 v5 b8 x* V* ]2 _ 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
8 q9 `, f; X9 W, ^$ u 方式一:# B S7 R% D# M, n3 e6 W
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
9 [+ E! J. n% Q' r I 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
$ O* q3 j+ f& L HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
7 ~8 y- I3 F. i; X2 c" Q, f: q( f; u 方式二:- a( e' d0 t: r- J
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:9 W- w5 ~- O9 j! U2 `4 P
SetTitleMatchMode RegEx2 s* r$ g- `& f$ A% o( t4 R. z
return/ B s% n' `8 K: {) q7 P4 T$ I
; Stuff to do when Windows Explorer is open
$ n+ o- W% \1 z% ]* J8 |1 @ ;
) M$ p% f+ J! W$ A6 K #IfWinActive ahk_class ExploreWClass|CabinetWClass; h& t( P% W4 Q& I
; open ‘cmd’ in the current directory
8 T; I X! S0 o ;
+ D- O# }) r- S7 A #c::9 [$ |7 _; w, K7 U9 I- Z
OpenCmdInCurrent()
% w* Z5 P" k1 n return
2 H/ |6 q4 M+ x #IfWinActive
8 H8 `0 K2 Y1 `! }! l$ ? | ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
! k9 i i% v3 x2 g5 z ; Note: expecting to be run when the active window is Explorer.
, p" @/ k/ l, K, m- b3 ` ;6 L( e2 S" V2 R1 F1 D; C1 X) X
OpenCmdInCurrent()
' v+ r1 t* M+ \/ S {% y- `* n4 Z% O1 {
; This is required to get the full path of the file from the address bar$ ]" P" L! s/ s# L" \
WinGetText, full_path, A& s5 p: c2 v; E6 F! o& B
; Split on newline (`n)
( `9 I: U( Z5 O. ^; `) U StringSplit, word_array, full_path, `n/ G! q9 d; l( h/ [, n5 y4 s
; Take the first element from the array5 F+ B) r% D; P. T6 Q
full_path = %word_array1%
8 X: k" L2 Y! f0 L1 B3 ^ ; strip to bare address& F5 I' h. x0 Q: i: d O0 e; N+ w
full_path := RegExReplace(full_path, “地址: “, “”)
4 a, _( W0 q4 W; ^! a ; Just in case – remove all carriage returns (`r)7 P- X! r* n, G r3 H
StringReplace, full_path, full_path, `r, , all! ^6 L {. H# A
IfInString full_path, \
( l$ P% p$ X- {3 P+ p+ K! I {
2 r% U- B7 c% G. i& A Run, cmd /K cd /D “%full_path%”4 G4 }: H8 d2 E! x2 v1 @0 p0 I# Z
}' f5 U% G. A2 P: K# E
else2 A! C% d) x" `: I! ?
{
; A5 x/ C' ]; [4 q+ C9 b# n) d% a& m Run, cmd /K cd /D “C:\ ”! P, ]* X8 r' d, A6 z* L" t/ h
}
7 \( v, `9 {& D9 I3 i }
& a/ y! O. ~9 o* f 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。* o& B! M( Y! h h
这段小代码肯能有两个你需要修改的地方 z2 d6 N. ~3 \ u& V. u/ d' K
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键# L1 v1 [; b. l: L. Z8 R
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
; V% i! r( f+ v* h# @8 h- h7 V |