此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。, G7 E+ K% v, Y6 o' ~
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
; b5 G9 J7 X2 i7 T5 M) }1 ` 方式一:1 U/ u4 ?7 B5 N- ^1 ~7 J
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,# [0 q/ }9 R/ ~! l% I
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
# t" |+ t4 U& E2 w" X% B" b I HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
) a8 A* {; P8 b 方式二:& e- s' ^% `" W
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
% G9 O9 ^0 O$ [8 ?, r SetTitleMatchMode RegEx: I5 M0 D3 F9 `& ^+ r, S- w
return' p- z3 M8 I8 ^( U3 p! o
; Stuff to do when Windows Explorer is open+ P, X- x+ e% t
;8 j& \1 q' i/ M$ v8 f7 g% B
#IfWinActive ahk_class ExploreWClass|CabinetWClass" j. b$ x7 ^# a# p/ L; I" O5 ?) S
; open ‘cmd’ in the current directory2 X9 L; ]6 s+ G% I2 ^8 r% S0 ^( l
;) u/ V+ z3 T: E( q: {
#c::
1 X v" V$ H& ^ OpenCmdInCurrent()& k7 [4 { U2 L7 t$ l! j
return$ p* H) v" E2 b0 L3 |9 F9 R! t, M
#IfWinActive
% h$ A8 ?. w/ }2 q' M ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.: Q, v& S1 d% k. K
; Note: expecting to be run when the active window is Explorer.: O) ]: {. n p, b$ u2 q
;7 h, }9 w0 q/ Z1 L
OpenCmdInCurrent()8 {; t' O0 B! z4 G/ G
{
( n" i$ ~$ p' [ ; This is required to get the full path of the file from the address bar
; \: L# s! @0 _7 c7 T. G WinGetText, full_path, A+ \6 b$ Q' u/ f2 r1 f
; Split on newline (`n)
: ]8 }. b6 ~' I8 R StringSplit, word_array, full_path, `n
- H4 R8 A; g& i( V2 K9 [3 [3 s ; Take the first element from the array0 V4 C- }2 C J( o/ y
full_path = %word_array1%8 b7 v) W! Y1 G4 T* Z
; strip to bare address8 l: F" p; j5 u* S* f+ y
full_path := RegExReplace(full_path, “地址: “, “”)
7 q, w" t3 t0 _* q# p2 O3 {$ K! {6 s- O ; Just in case – remove all carriage returns (`r)
' T2 i: D! A2 {0 A2 b StringReplace, full_path, full_path, `r, , all4 j% Y" m/ S/ ]" B! u
IfInString full_path, \- ]" L+ Z! i8 _9 k5 ]
{+ ~' ]# F, \" c N( }% o
Run, cmd /K cd /D “%full_path%”4 ~% q' c1 T& g- J5 G
}2 H# o7 P: i6 A5 e
else
& e2 E3 ^4 Y, ]6 F+ U {
! j8 h, T, _/ k5 m: h" i) E6 N9 T Run, cmd /K cd /D “C:\ ”
, C! s/ E; C2 M" c, e0 j/ p }; m+ f& n3 ]& Z
}
/ I* u2 y& e1 E% w: W 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
2 K% s F, T3 y" q; N/ ^& W7 U 这段小代码肯能有两个你需要修改的地方
! @8 e* c4 v$ c4 v" ~ 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
( u3 U; D9 E5 k$ @2 p; A0 u! B% N 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “9 D) c4 ]+ J" u; Y8 [
|