此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
7 X* k. f6 _4 d8 c; J& Z8 y 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
- |) ~" g% g6 z6 }, W* s$ ? 方式一:
4 _; y0 F( K$ k5 r% Q2 @5 z 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,8 r2 l/ [+ \9 J( z, S2 @
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和. e' s- I1 U3 V2 q4 A
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。9 z5 _/ e Z6 K: v# `
方式二:
: y# A$ p8 f* }) L: {( F' \ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
/ g: k f9 B; U1 v SetTitleMatchMode RegEx
) E/ a8 j( J! \' e& z& q- f: a return
% \0 O" e4 u3 u; K4 ` ; Stuff to do when Windows Explorer is open
8 S& u6 {; `) D( e' c7 A" v L ;$ X0 V- h4 w7 W" O# O
#IfWinActive ahk_class ExploreWClass|CabinetWClass( i$ H! h& ^# v7 t6 i" I2 g- G
; open ‘cmd’ in the current directory, ^4 t8 K. K1 o2 S5 {# |
;+ c4 ^; i" R7 c: {
#c::( J( u1 M' b# j2 \' @. N
OpenCmdInCurrent()
& j* X; o. G9 k! Y; z, n: X return3 U# i+ G- j9 {5 b+ \
#IfWinActive
, z) M& _/ M" n; m- }4 T* m ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
. a) \/ j" x7 o$ a* }* P ; Note: expecting to be run when the active window is Explorer./ f$ I R& X& V9 u" @9 |9 J, }6 B" U
;
3 Q* Y2 g3 f6 x+ F& Y OpenCmdInCurrent()
M, P3 W* }) p {
" q5 t+ L0 {& u+ n ; This is required to get the full path of the file from the address bar% ? K& h' V$ d5 B7 j4 E& s9 f! U
WinGetText, full_path, A
1 ?, z, J: e: }7 O+ f' t6 ^0 z% Z ; Split on newline (`n)! [0 i5 c1 R9 r
StringSplit, word_array, full_path, `n
5 A* D/ u |( ? ; Take the first element from the array
9 K" A, I A" G* l5 ^9 k full_path = %word_array1%: P5 l0 d4 _! T3 }8 ?9 h
; strip to bare address
& g2 y9 z" N( p/ M, \ full_path := RegExReplace(full_path, “地址: “, “”)3 Z' E0 I7 u8 E; @: E
; Just in case – remove all carriage returns (`r)
, D! A; W. M' v( s% h! @ StringReplace, full_path, full_path, `r, , all
; e- e: F4 C1 F IfInString full_path, \0 x/ p w1 z( {5 m
{
! J; {6 W) G) E$ A! f; s) L9 I Run, cmd /K cd /D “%full_path%”- f( n& R( b. ~7 T3 \# [
}+ ?3 [3 M/ q- e# ~' B( D" _* I9 Y
else
0 B' K" F8 z5 j7 d5 z2 ^ {" J3 w. I: ~, _
Run, cmd /K cd /D “C:\ ”8 ~# `1 w9 |: G. Q$ U
}, j' W4 Z0 b: O7 ~+ x
}
" M3 F# a! M* o4 i, R 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
; a) z" E7 g3 i& J$ m: I8 C& I' T 这段小代码肯能有两个你需要修改的地方
' z. Y) b! `0 Z, B3 J) M 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键9 c3 ]! D# h" Z( X8 w- B9 I( ?
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
% T# p: g, q! n7 @" a0 u0 C7 B7 s |