此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。$ w) N6 I' f& m( i4 }
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
D! t2 r# [. o 方式一:
+ c+ l1 ], j* e! h, c4 L 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,& E$ k O+ Z* e9 }. [ ?
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
" Q: v+ o) s, K/ f HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
# X* m$ q8 x# x 方式二:
! {, y, ~; n: U0 K 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:! Z" n, i2 r6 w. S; b, k$ d1 _
SetTitleMatchMode RegEx
" Q2 u' I0 S" j, R, e return, [$ X; I0 ], K, b9 O" k- x7 u
; Stuff to do when Windows Explorer is open, G% [* j. x! u
;0 f! f2 ~& ]: S1 E& `
#IfWinActive ahk_class ExploreWClass|CabinetWClass" Z+ c/ l7 h% h; l: w
; open ‘cmd’ in the current directory
( \, z, }5 v3 T! D; K/ \' w ;
/ Y+ b8 ?% d# i& n/ S #c::
5 ^) C# z# Q3 G% p$ n( l OpenCmdInCurrent()
8 W, i1 B" Y8 Q return
' O5 U2 X' C# f7 V4 I- ]7 ?8 A8 w #IfWinActive
- y' x/ E1 T4 o, @ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer./ z, }/ T1 G8 {7 y
; Note: expecting to be run when the active window is Explorer.
H0 L8 a7 S) V& x" C8 t, t ;: g8 K5 i; b1 V# c0 @
OpenCmdInCurrent()
& s7 Z$ Y. s5 ~. H: k% b4 e- Q {! s2 h& X% t5 g9 j4 T9 {$ F$ R
; This is required to get the full path of the file from the address bar }4 C0 @: J4 o& L$ x# u4 ~
WinGetText, full_path, A) u$ @& `' ?- A. b7 y/ A- F3 F: ]
; Split on newline (`n), V( R$ d2 a8 E) R8 z6 `6 Y
StringSplit, word_array, full_path, `n( d3 V2 M6 [7 A. B: M, S
; Take the first element from the array
4 U- m8 p, ~) A) c full_path = %word_array1%
, j0 F3 U4 r. C8 j ; strip to bare address
. P) k8 b$ H2 w9 t3 I full_path := RegExReplace(full_path, “地址: “, “”)! r* ]9 u, u# i9 _0 B; u
; Just in case – remove all carriage returns (`r)
3 j9 S# g% F, e( C+ Z' H; z: Z StringReplace, full_path, full_path, `r, , all/ B9 J0 {3 [* m* }" b
IfInString full_path, \
$ x% n, d x+ N7 W2 Z, v: T. Q) L; ~ {% }7 J1 c) A& d& I" F
Run, cmd /K cd /D “%full_path%”
6 U) N7 [5 w2 Q% }' W3 v# b }( t6 G2 p" z1 y; d5 G
else2 ~5 [4 w9 S- L6 L% D
{
2 {6 V- ^& K; @( d9 L# G Run, cmd /K cd /D “C:\ ”
% Z$ }% C0 I8 ]+ U' ^/ C }
' H+ S$ z; z6 o) h' }! z6 }- | }
u* q- D, C" }2 l, i 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。3 G+ K2 D- v! G) @; {. P3 M
这段小代码肯能有两个你需要修改的地方
2 k: m0 f' F; R3 } [6 ^: Q 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
. _. m N$ d: C/ {1 H' [7 }. Z 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
9 M( M7 h6 N$ t# R$ J3 E z+ O$ z4 i |