此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。( B- L# n& C8 r- H4 e
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。( X P4 C# O# D# s2 N8 o4 H
方式一:% f6 `8 W' D/ o; m2 N. R2 A
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
6 g# M6 q" N; M; U" _, K 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和+ E; R+ Y. S6 z6 t
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
( Q4 H9 \* |4 u0 [' a 方式二:
1 e; n Y, N9 \6 w' F7 y 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:" K+ t# d3 P' E3 c9 ~
SetTitleMatchMode RegEx
+ i* z! Z* _2 F" Y9 R% D return
0 y1 P8 V7 z1 T; W J7 N8 g ; Stuff to do when Windows Explorer is open
5 s" B! h$ l( D& B) z ;6 H( e3 S: N0 }
#IfWinActive ahk_class ExploreWClass|CabinetWClass
. h0 a! e" O/ Q! F. L( M ; open ‘cmd’ in the current directory2 d' ]9 N$ i$ \! u' n. C+ k
;9 w; |2 D8 h% b8 n
#c::4 Q# D$ o+ a3 {1 j: e1 z5 @
OpenCmdInCurrent()
& y3 ?+ Z9 t4 |8 i return1 t: k& y6 _- l% |$ G$ x
#IfWinActive/ ?4 ~3 }& D8 a" ]# E: j0 W
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.1 n3 {+ P: T: v6 |( x6 F
; Note: expecting to be run when the active window is Explorer.. V( Y+ D4 V+ f% Y
;
6 L9 S& ^8 T% N( }% C( P OpenCmdInCurrent()
' {% v# J) |. d: B% [ {
9 _4 j/ a' Q7 Y/ U ; This is required to get the full path of the file from the address bar
+ G8 q* @0 Z$ D4 l WinGetText, full_path, A4 a" f$ W! I- O9 v# R8 i
; Split on newline (`n)
3 [. o% n' w) H: n/ {% ~ StringSplit, word_array, full_path, `n
$ I, `5 B, Z$ G ; Take the first element from the array/ G3 M6 S& S1 T$ z7 x4 o0 d5 v
full_path = %word_array1%, @# v, E5 _% z7 j; L
; strip to bare address
% T- r/ k9 W# g3 m5 |; } full_path := RegExReplace(full_path, “地址: “, “”)
6 ^% G R) }# y, b: E/ W ; Just in case – remove all carriage returns (`r)7 T( f) k( ~4 J& l) X! N8 I
StringReplace, full_path, full_path, `r, , all
% Q) ?4 o) r0 r+ S; a7 P3 Z IfInString full_path, \5 l4 a8 q1 s/ A2 P, q
{
: F+ R" Q6 w g W' ^0 X5 W" S( | Run, cmd /K cd /D “%full_path%”
! P+ W( z+ j7 v. T8 l8 T4 ~ }
1 U% j" @9 i7 @* y7 W- e" B else* n7 Y- z/ [6 `8 m4 d q0 p
{3 e m7 N5 e1 y
Run, cmd /K cd /D “C:\ ”9 b# R3 Z# I8 r' V. ~
}9 Q( C. l; h0 O6 ]: |9 L
}
2 g. l0 N; `/ |8 o( y+ p 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
7 r" F# w! c$ v! `1 r- `7 i 这段小代码肯能有两个你需要修改的地方8 ^' O# n- s/ R+ k
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
4 p0 @% w4 `7 m" S3 o 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
9 O; C1 L4 u) `* ^$ e ^/ Y |