此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。# a4 f; K9 N$ p3 n4 M- q6 N
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。) D, y9 N7 @) _3 \3 o' ?9 F! t
方式一:
8 F- t! c+ A+ m 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,0 N) P( x4 ]* }' O8 [$ {+ D, z, X7 I
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
- [1 J [. X& j1 z `+ N HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。9 q# \* U8 e- ^1 S
方式二:
5 z0 Z2 n3 ~; t# i5 n 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
. v" ~: X4 h1 X U8 a: s% ` SetTitleMatchMode RegEx& h9 O% s" ^+ w, q: P1 x
return
( e+ J! N" h/ t, M1 j9 I# T1 Y- x3 u6 k ; Stuff to do when Windows Explorer is open
+ s2 h' Y4 G, y/ D" t ;, w" Q4 [& `8 ~3 V7 ?; V' v) O {
#IfWinActive ahk_class ExploreWClass|CabinetWClass b/ ^4 E) B4 R$ `! J* R# \
; open ‘cmd’ in the current directory. N" v, w8 \/ X" N
;: G# w& M p, I
#c::
; C/ ~( g$ J! Y- s OpenCmdInCurrent()- K0 S) F R& `( {' }' ^( {
return9 D0 C6 l5 |) P. n7 Q6 A& U: I e( \
#IfWinActive
5 \# J! s5 N8 |; X ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
: {$ B% X9 E/ t7 N- [4 X ; Note: expecting to be run when the active window is Explorer.6 y8 ~( W, \/ N. g% h- F
;
8 {; n2 z. z0 ]3 C u OpenCmdInCurrent()9 n) O/ R! F8 a) D6 y4 I
{
- j0 w8 ~! ?- U, a* W( V) Z1 E" Y( R ; This is required to get the full path of the file from the address bar
+ F) o* C7 R8 Z% c WinGetText, full_path, A! t- F5 D" X$ d, `. N. a3 m
; Split on newline (`n)
& T' X3 `+ a$ s- I9 ] StringSplit, word_array, full_path, `n
* c4 {, x' b5 l; ^6 e7 u7 Z2 R ; Take the first element from the array$ g! m5 U; n' U/ N( ~. z+ `
full_path = %word_array1%
5 S0 b8 v& u' k H! L ; strip to bare address
: }! K9 i0 h+ q& }; e full_path := RegExReplace(full_path, “地址: “, “”)
% C/ b3 B: h# q& M, ` ; Just in case – remove all carriage returns (`r); b8 W2 D$ v; m5 r6 V: X a3 V
StringReplace, full_path, full_path, `r, , all2 I a) p% W" W7 k- |5 S
IfInString full_path, \1 x/ }( A; l y
{
9 {7 z7 F' [& e* A7 r F2 e$ V/ ]7 Y Run, cmd /K cd /D “%full_path%”/ k5 d; J4 D: Z/ u7 Y
}
: c, V0 _- j* J) r6 b else# ~/ o' T, |# Z( d3 _' I: W: V
{
+ J1 ~7 `" o! b& X `$ D( O Run, cmd /K cd /D “C:\ ”. t) ?- y1 y( r1 X
}$ K; p+ ]# p2 [$ c! P8 w
}
, g7 d" A+ ?6 _& m 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
! T1 r! t, d& ^ 这段小代码肯能有两个你需要修改的地方; a5 }2 t6 ^, c: ~( T& V
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
$ u% _+ d' b+ e' [ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
2 j. p+ O+ `6 D* Q3 H: W, o |