此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
: O! r- H( C v$ ]. F 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。7 x; l9 g: Q' i
方式一:
* U! H) [: ^% k 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
# e ~' V+ D K 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
+ C1 \& g& _& E' U8 l1 t HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。( g+ X/ m! F$ t. W' q; x
方式二:
! K" v% h8 E8 V 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
& s8 k7 i3 A; D7 \- a: u SetTitleMatchMode RegEx
- W7 a8 n6 }8 W4 E: C4 x return
* h( h: D$ g' p$ s$ ? ; Stuff to do when Windows Explorer is open6 Y1 D* V9 }$ W1 z V0 P$ B
;
8 r* ~1 Q) z% a; J #IfWinActive ahk_class ExploreWClass|CabinetWClass3 Z" S" G- F* k( F6 I
; open ‘cmd’ in the current directory
) k5 {8 m& k n4 G& f ;
0 E) E$ ]2 Q& k" N+ a% n" q #c::4 G$ Y; V+ Z' C+ [$ r0 ^/ l4 o
OpenCmdInCurrent()
1 H$ g: ]) \5 G return9 a: @* }* C* s0 `! Y' ^
#IfWinActive" u4 o5 N. `7 w4 H% X) M
; Opens the command shell ‘cmd’ in the directory browsed in Explorer., n3 y1 o. D6 g# g/ y; T; {' {
; Note: expecting to be run when the active window is Explorer.
, X/ k/ {1 r @ ;
& Z+ m* u+ x/ p6 F6 k& d/ s" k OpenCmdInCurrent()9 x7 [- ~& B ~/ b/ [) L) s& c
{
' @, g* ]' h3 k' y6 ?' G5 S ; This is required to get the full path of the file from the address bar+ i$ H5 ]' E; X7 a9 F
WinGetText, full_path, A
, ~4 Y% P$ M) [- s$ T% @ ; Split on newline (`n)' S' r# N" U; t x8 S& j# g
StringSplit, word_array, full_path, `n. b7 ~( N: c; k% l' w
; Take the first element from the array" g& X* h, i. s$ I, S" c, ~
full_path = %word_array1%! C0 u( H/ g1 l3 ?; L3 W
; strip to bare address- `4 | _' H# M, c, z$ j
full_path := RegExReplace(full_path, “地址: “, “”)& T$ m4 P5 Y: ], I
; Just in case – remove all carriage returns (`r)' F7 X+ Q6 L* V. h$ X
StringReplace, full_path, full_path, `r, , all' f. ~7 g# B$ y2 c! ~
IfInString full_path, \
' A" B2 Z9 k) a$ d1 u {
7 Q& V5 B5 S# i7 b/ S' k' d' F9 _ Run, cmd /K cd /D “%full_path%”" _: M% Q: R) m7 Z: e
}
0 m4 L4 k5 Y/ `9 R' h else5 L( A" _3 X6 q( ?4 Z& ^# U
{
Z& m% D% @. a6 b Run, cmd /K cd /D “C:\ ”
2 H$ p% Z1 X A/ s" T1 j d/ t' ~ }
: [7 ]: ~1 F/ ?2 } }+ H1 T5 {6 X! i; C
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
6 W6 {' _% K" T) b* e 这段小代码肯能有两个你需要修改的地方/ k$ K3 _6 K. O. p/ C2 K
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
% Z6 H* T5 ~& ] 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
8 u# A; T! X/ Q+ D& \6 j: B |