此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
5 v/ q' T4 w9 k7 w9 R 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
1 w2 E. U+ z3 g 方式一:0 E" A0 [/ d3 D
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
, n3 T6 X4 q: b# N% M6 P) `6 T 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
' E7 b! M7 h, K K8 w# a' h HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。5 I7 @7 t( y: L; V5 D/ `
方式二:5 X2 C( G- U$ f3 r% _
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:; [; B# {: U$ E6 a
SetTitleMatchMode RegEx
" f, W5 _! H' v* g1 o9 u return; _6 X) x9 K5 {0 G; I. e
; Stuff to do when Windows Explorer is open8 E3 V- H& a2 [3 `) i
;
7 l; m, S H/ c _8 z #IfWinActive ahk_class ExploreWClass|CabinetWClass2 ]$ d! D; q- j/ r i$ ~9 X
; open ‘cmd’ in the current directory1 T3 Y3 D) N/ L3 e8 |
;
- L, j0 m1 R2 w0 p! e r #c::( e$ a4 |, X- N+ A
OpenCmdInCurrent()8 Z7 b8 P7 l7 N/ S& r2 G
return
o3 Q5 p$ L* u+ Y z( v5 o) c #IfWinActive
5 V2 o# r6 Y0 K ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.1 F5 l ? O, L" j9 J& K9 Q
; Note: expecting to be run when the active window is Explorer.: [6 y. a6 P5 e; P
;
- S4 N6 c" q3 W; \( l OpenCmdInCurrent()
( E0 s# U* ? t R! A" X {! k# m v! h- T( j" M) N* V: c) \' Z4 u
; This is required to get the full path of the file from the address bar
6 Y* u7 L$ H( w7 e( M' x- B, u WinGetText, full_path, A5 E7 q E6 a* T' _6 I/ y' x
; Split on newline (`n)4 J. k6 g2 ^# U# R& b/ x9 H
StringSplit, word_array, full_path, `n. X/ B, |9 j9 J3 k$ ?
; Take the first element from the array
* u/ z5 u! w' I$ _7 x7 I% x full_path = %word_array1%7 \* E3 K o% ?" u" W. S
; strip to bare address
7 j3 v7 ^" D) q! F full_path := RegExReplace(full_path, “地址: “, “”)
3 A; u4 N. B- r+ Y. j- _ ; Just in case – remove all carriage returns (`r)$ P0 I4 v' l: l8 r# q& I! H
StringReplace, full_path, full_path, `r, , all
* g5 q* Q- g6 ?2 v* t) `+ _ IfInString full_path, \
! n" y- A, C, o8 O) _ @3 H {
" L) C( \! D- c' H1 `% j3 k Run, cmd /K cd /D “%full_path%”3 B* ^8 d5 o$ D4 L- y4 e8 O
}6 P; n8 K6 _: [! ?* F( B) {
else/ _! L4 o$ F6 x- e. }- E- m
{
! |( L5 h+ E, v1 m Run, cmd /K cd /D “C:\ ”
" O8 Z4 Q! x/ g, ?. _! h' r( V$ K }6 L- B0 E. [1 `; @! r( m9 ?0 {: S
}
v4 M- [. Q9 x4 v. p9 _0 h 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。0 s* _' n9 i3 t. Y
这段小代码肯能有两个你需要修改的地方, a8 Y2 v2 ]* o$ P2 p$ c' s
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键7 r$ I9 e% i$ K
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “. n/ X- D( i. D R2 g! d
|