此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。' ^/ o7 B3 Q: S; [/ [& U
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
2 g2 l! A/ }6 E 方式一:3 } {8 v! s8 q/ U9 f' |
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,! Z, k# a' I# V. O) I }, x# ~
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
8 [1 s2 f1 m) A' M+ D0 m0 v HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。% J( Y7 P$ n. N7 \9 p
方式二:
/ S: r' ^1 x( O4 O( L+ b+ m+ i 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:0 S$ }' l/ v; t' I5 J5 Z
SetTitleMatchMode RegEx
. P& f9 z! i* j) v+ C return
! X( [9 h, h, t8 g0 Z( ?, @. o ; Stuff to do when Windows Explorer is open- O6 o' O1 U6 y2 W# P* q9 K: p, t( R
;
, H: ]1 x6 |4 i' l9 G2 I/ G% D- J& | #IfWinActive ahk_class ExploreWClass|CabinetWClass$ Y2 @/ h& u/ x# P8 k. |
; open ‘cmd’ in the current directory
0 j/ o* {/ d' Z4 n8 W ;
8 b+ s0 S# \% b7 ?: o #c::9 ]! [1 A( Z6 n
OpenCmdInCurrent()
& _$ J) b Q1 M% Y return1 w7 D# ]; H! p# J- {7 N( e
#IfWinActive& G( ^6 X/ [0 f9 B
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.: E8 U# _ n" l8 O
; Note: expecting to be run when the active window is Explorer.
2 m+ J0 V& t9 G; S4 X8 k+ W" |) v ;
; \0 y3 C: r( b: y OpenCmdInCurrent(), k; Q+ G2 b; n/ h* P
{
7 N& c* j3 a9 e0 C. }1 I e3 e7 E+ f3 I ; This is required to get the full path of the file from the address bar
5 K3 A) t4 H" v, O WinGetText, full_path, A# E( m' @1 e* Y ~" v1 t
; Split on newline (`n)6 l5 C+ }, H; h4 }
StringSplit, word_array, full_path, `n
" Q/ O& a' Q0 ]! k. T! J ; Take the first element from the array1 A; m* f. b$ _$ @
full_path = %word_array1%. B! L3 y; ^' ]9 l" ~/ l3 `
; strip to bare address9 G7 w2 p% A8 ]. S( I
full_path := RegExReplace(full_path, “地址: “, “”)
. n- l2 ]3 f1 h# W4 d ; Just in case – remove all carriage returns (`r)
1 h, p) e1 o9 d3 I StringReplace, full_path, full_path, `r, , all. U m$ l' U" S+ o
IfInString full_path, \1 S+ F+ a+ Y1 V3 r! D2 Q- `0 q
{! B' Y( m" o. O s& z
Run, cmd /K cd /D “%full_path%”
' g6 X3 `, h2 h. \1 n& ~ } k1 Z# K7 w& V! w' m
else
0 {( Q& S; D: J2 C7 f. ~ {
% c# [+ i- o; x) ?7 f9 E Run, cmd /K cd /D “C:\ ”
) u5 D4 N1 N" v$ A) K$ { }+ |) U+ F# H$ G# \# x* E
}7 F) B5 C( b8 x$ s
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。0 b: I0 L& y4 K K+ P1 O9 H* M
这段小代码肯能有两个你需要修改的地方# `7 @$ U# b4 I3 E$ p. B; F
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键; ?- N# [5 I: ?! D- T. T# e
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “. v5 g# A) |+ e, s% T& Z9 k+ c
|