此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。3 r# {" t/ ?" u7 W0 [/ C
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。4 `9 R u! u, ^- l
方式一:
3 S/ ^- p, v6 T" s9 h1 [ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
% p7 B' M3 U: u$ a 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
) U/ I4 m. k' _ |0 } p+ h6 g4 J6 A% x HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
5 ]; F7 F: ^5 v% Z% Y7 B8 S" V1 X4 q 方式二:
9 r3 O8 }7 g) j; o+ {/ N$ W% h( V 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
5 [) _' u. v8 R- ^$ q! n SetTitleMatchMode RegEx
* I; c3 _/ }% Q* r. i return
. x9 E! m1 }; W( g/ i, ? ; Stuff to do when Windows Explorer is open
- C7 g) x6 p0 e/ ~8 W ; _: K3 G* E8 [! {" \, L
#IfWinActive ahk_class ExploreWClass|CabinetWClass6 g7 J3 X: J" k0 S2 `
; open ‘cmd’ in the current directory
$ w) H( `; @4 o, A ;
! [0 V! }' n, }5 B #c::
% o X% h7 D8 N' X: S0 S OpenCmdInCurrent()
4 R, |0 T4 B) y( l3 G6 z return( i, e7 Y6 r# i- A) q0 J
#IfWinActive6 R( }1 Z; q6 F* L6 M V
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.* x- I9 D+ I8 C4 q7 \- N
; Note: expecting to be run when the active window is Explorer." V( P6 g% N3 ?; Z) A
;. Z0 N9 R/ r6 X+ m$ w. B9 P( |
OpenCmdInCurrent()
. f0 y& _7 g2 t3 X {
- k' ~9 \5 E/ K3 o ; This is required to get the full path of the file from the address bar0 j% l" W2 L, {8 c
WinGetText, full_path, A
/ a" F4 T& f$ m4 U& G$ J9 e3 N ; Split on newline (`n)5 N+ n% ^. t4 j# f/ p& N; ^% J$ K
StringSplit, word_array, full_path, `n1 P$ M$ m2 F9 K$ H
; Take the first element from the array
, H% d! a l) d1 n% C/ _9 n% J- ] full_path = %word_array1%- d6 }3 Q) }% q; t: n! I
; strip to bare address0 C. p! C2 f1 a$ B8 j$ u
full_path := RegExReplace(full_path, “地址: “, “”)
7 V, i. M% [5 y9 j, k ; Just in case – remove all carriage returns (`r)) ~( j9 Y8 X& V' }
StringReplace, full_path, full_path, `r, , all
! t/ y7 m9 H3 K/ g IfInString full_path, \
) J+ W4 [ h# u; O) V& m$ F {
" W9 [2 z" @# K M/ |* o Run, cmd /K cd /D “%full_path%”
) z. s- _ H2 }, V } i2 a! q- l2 G
else+ [5 Z1 G+ N8 x( A5 B
{* `9 t" F0 h7 o* q; R
Run, cmd /K cd /D “C:\ ”
9 b# ]/ s1 z# j }
: |2 e7 T$ k1 ?, P }0 |& v1 O- v$ r/ H O) V. I
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。: w* k% T& ~* V- a* ?% o) O) b v. C
这段小代码肯能有两个你需要修改的地方
, d) D6 V6 U& U: D 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键; k: D1 J4 c: n! F8 H
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
) |! p' }) |" _* Z/ z+ W; ] |