此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
! {: T/ |- D0 R, i: p 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
& a! T; p# Y5 C1 Q0 o8 P8 O 方式一:
( e7 d) H `+ @7 s 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,9 `0 u: @! h4 J7 T
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和! R1 u$ j# X) N& q* q" |0 M, m$ ]( M
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
* N1 V4 L1 v( G$ H/ | ?" N 方式二:3 @& t' K$ e" I; c! ?
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:: ~5 G" C/ h& b0 H
SetTitleMatchMode RegEx9 k) x- H7 Y! t! m% ~, G+ R
return
( O! T) s/ |3 ~5 w ; Stuff to do when Windows Explorer is open
" C1 T# ]$ n; u3 \ ;
4 C9 b7 A2 w& b z# i1 \ #IfWinActive ahk_class ExploreWClass|CabinetWClass% g' E5 w5 _$ u2 B* ~2 y
; open ‘cmd’ in the current directory% Q+ v: Z% s4 r- d( E0 @1 @
;# Z' ~ P; s8 U8 B6 r# s" N6 }
#c::5 D! o9 s) E0 b2 C' b5 j
OpenCmdInCurrent()
% y! ]7 y I4 l& d% s6 ]$ C return
! N( s/ E6 F2 b. b V8 I3 p- ] #IfWinActive1 g1 g i5 y; ]" _ ^1 n4 }
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.2 |9 d1 V& C: b. x+ M
; Note: expecting to be run when the active window is Explorer.
. E5 z2 B% m) e4 b* O ;
) C+ v. f& W- }8 t+ `7 W2 L+ B5 X; H OpenCmdInCurrent()8 N% Q8 c1 c4 Y0 a2 P: \
{
; |3 _9 \/ ]" S2 ] ; This is required to get the full path of the file from the address bar- E$ u+ }% c# V( e, p
WinGetText, full_path, A
0 P; x) z. ?* ]6 l5 C! t Y6 Q ; Split on newline (`n)7 \; P! v- {; h+ x1 [, C* k
StringSplit, word_array, full_path, `n2 j2 b, U8 R5 x/ _0 U
; Take the first element from the array9 X. T0 K( {9 D5 g: b
full_path = %word_array1%- W1 E' U9 Q. T( f6 Z
; strip to bare address! \* X c% B6 p
full_path := RegExReplace(full_path, “地址: “, “”)
" L9 D1 ?- Q W ; Just in case – remove all carriage returns (`r)
! d+ @6 Y s. w, s$ S3 t7 b3 y StringReplace, full_path, full_path, `r, , all
& z+ s! h0 w, W7 } IfInString full_path, \* t* @& d8 T" `4 j& t$ l" x
{
7 S. I$ A( I5 h! w! b! `* D+ J Run, cmd /K cd /D “%full_path%”/ K7 t' S0 d& w9 b$ [" Z5 h2 f
}. ^" _- f C' z' E
else
8 n6 a7 x( O# G- F0 e {1 r. x/ P7 I& I( C) P! R
Run, cmd /K cd /D “C:\ ”
/ m/ ]5 W3 M, i3 a }
- z, d* e/ \9 o }# t0 \0 ]$ \& P8 ]/ ~4 N
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
2 M1 D* j, Q n7 E n a, z5 ~ 这段小代码肯能有两个你需要修改的地方+ {3 `/ u" K$ ~
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键9 z2 x! u5 D; x' Z0 q8 Q
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
' Z2 N$ U$ R1 ]. U, j |