此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。; z4 g. e; i5 |! E0 t- |1 [
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。8 B7 h: i( G+ S% D ]! N3 F
方式一:- F( G, E0 F; S" ?
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,* z% f1 J2 m( ~: B7 y! n
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
- p. U* B: r4 w. f HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。6 J2 G3 |/ ^- ]% D( F/ @# }
方式二:
+ R, i2 Y. f. i. E9 O# Y% W 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
$ ]* a3 W. N7 a- G* s* n/ w# H SetTitleMatchMode RegEx
3 a; F' l1 `! m4 P2 x2 ]1 f. Q return
& j9 W4 A9 D( B7 _ ; Stuff to do when Windows Explorer is open
! D; w8 O. U z; L+ F+ \5 d ;4 h) w# R( w( f8 ]1 b
#IfWinActive ahk_class ExploreWClass|CabinetWClass
0 X' `7 ^/ l$ k, X ; open ‘cmd’ in the current directory0 o, g y& [5 e; m! S6 B2 D$ w# f
;
$ Z' d: I9 Q. j8 S #c::
, Y0 E% w6 H; I- M! i( A. _' r OpenCmdInCurrent()% G0 L+ t& j8 x# c8 Z
return |* @- \& w9 r6 d3 m1 Y: |2 j
#IfWinActive
, E1 w9 z9 w: e% Q8 @ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
# [3 |/ `1 m6 N) m8 K8 o ; Note: expecting to be run when the active window is Explorer.; I3 K/ u$ S. T
;8 N6 [$ B3 s) r, E( ]! @' ]
OpenCmdInCurrent()( o# g* s9 X9 @9 D& n3 u
{
. k5 x% J$ f/ [# J5 P ; This is required to get the full path of the file from the address bar
4 ?' f9 b5 a: J* q$ ] WinGetText, full_path, A) E/ o. q5 E, ?- E5 F
; Split on newline (`n)
* `; \ g% G9 i$ s( V& ~ StringSplit, word_array, full_path, `n
0 ^. ~" `5 e* [ L: [# Z6 L+ ] ; Take the first element from the array3 A( |1 N$ I/ e& x
full_path = %word_array1%5 q! B; R" J# g! o& ?) y
; strip to bare address
; V% k$ L) W1 F9 a7 x/ j9 n3 t6 L full_path := RegExReplace(full_path, “地址: “, “”)+ }) g, h3 k; B3 B9 |3 j+ t. b; ^
; Just in case – remove all carriage returns (`r); r' A( ^' L, o" X
StringReplace, full_path, full_path, `r, , all
9 H# T9 z$ K* B5 ? IfInString full_path, \
" w5 d1 F8 K) h5 }# Q( f1 \ {
! m5 m) `4 k8 w$ Q: i% l* @ Run, cmd /K cd /D “%full_path%”$ M" H. w" F; z: s" L! o+ Z. O0 G
}
' X& ~' t) b# F3 W, N% z" P; ]) u else
6 T" e# l8 a" ^; ~# T: r' @ {- H0 e7 g1 K8 B0 K6 p1 E9 ]
Run, cmd /K cd /D “C:\ ”6 I, e# H& C4 [" U
}
- V- J Q0 F7 u }
& I. D& ?8 _7 r5 q 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
7 q* Q- k+ j6 [0 i& H 这段小代码肯能有两个你需要修改的地方
- {% n6 w4 |) `- r+ x 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
5 t/ Y, s* c' w$ h5 j 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “( `6 q5 \. }! I
|