此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
; b$ n8 j3 P9 n9 S# T. ^ 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。! N+ K7 F. C+ F- W. s6 l
方式一:9 e' ]6 G5 n' m4 c9 c
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,- k7 Y1 f* d8 [1 {
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
) H: _+ a: f" i6 Z) ] HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
! }9 P; g: \6 N) B2 Z( ` 方式二:
' n* t" z& _; C' V1 K: j& k! { 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
( Z. G( P1 L) _4 I SetTitleMatchMode RegEx3 r6 S3 j7 T8 P0 ^7 ^( M
return
+ @+ \! Q2 T7 E) j5 J2 O- b ; Stuff to do when Windows Explorer is open8 I0 U W5 m3 G% \" i5 J
;
% p% _' F# ~; l! N #IfWinActive ahk_class ExploreWClass|CabinetWClass& C' ]" ?& v( j+ W
; open ‘cmd’ in the current directory
6 O8 V0 h0 S; j( S% Z: b8 b ;
( \2 M2 @6 F7 G% l7 m5 W1 P4 z #c::
. M1 i' K$ g5 I4 F1 E3 r OpenCmdInCurrent()
+ i( X$ g6 L2 J- { return) _+ t& c+ Z* o0 x
#IfWinActive& J' P- j' }8 V5 w
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.8 v$ c. y3 `8 {' j! @
; Note: expecting to be run when the active window is Explorer.
; X3 X, e' q- q: K ;
* N4 U% x* A1 l( T7 m5 i" d OpenCmdInCurrent()4 X/ |% \% |0 o/ W/ X* n& H
{
# g) V. H* u. V ; This is required to get the full path of the file from the address bar2 b/ C2 R) _. x9 A
WinGetText, full_path, A
8 ]- w; D. M/ [ ~4 Q$ @5 r ; Split on newline (`n)
) u: K$ w" x# y6 R: v StringSplit, word_array, full_path, `n
6 {7 o: ]: H9 y$ r6 S% @ ; Take the first element from the array9 K( m/ G3 \, _/ j) c
full_path = %word_array1%
3 E6 ~, M' w; \" u$ x ; strip to bare address
! y- I3 d! I- e0 R& G full_path := RegExReplace(full_path, “地址: “, “”)
( V( A0 w# g5 t/ W) r ; Just in case – remove all carriage returns (`r)
' p, K+ `, w+ h, H! }2 E* R: M StringReplace, full_path, full_path, `r, , all& Y( x/ I1 v, o- g5 y# ~* k
IfInString full_path, \
( C# t8 K2 L* C. T% W& S0 W4 O {+ K% p* l5 I$ u2 r, y. T7 f
Run, cmd /K cd /D “%full_path%”
/ i, H' |; j8 ~ }
6 s% J% v) W# O U" m/ E8 u else1 m5 p2 P0 B; J! q0 W
{
" f6 F+ g% b9 S Run, cmd /K cd /D “C:\ ”3 V( s" A8 R* c/ m8 y
}
: f. A2 {% z; B& Y+ u7 Z& Q# ^: O }7 B: T5 g4 z5 l# D2 d! ], M
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。+ x$ w* s" ]% ?/ l" o- `& B
这段小代码肯能有两个你需要修改的地方6 ]8 s; V" h) T) O8 G
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
, W8 r. c8 P& T' d$ D* w f 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “$ h$ t0 n9 o& M3 k/ N& m
|