此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
. u: z3 Y* |4 A3 t7 L; }, Y0 V 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
# v4 j( H4 z+ D7 ~2 v5 F1 @7 ]# f 方式一:4 T3 Z( ]8 L! d' q- U
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
3 N) |& F2 B. J# i 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和" ?1 f2 r' T" P e* Z) e/ e
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。6 m" f: J5 M3 R; {+ `
方式二:1 g# P7 A6 G: v6 a8 A, Y
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
6 p/ b8 ~; b/ `' E* e8 w' x% ? SetTitleMatchMode RegEx
5 U( U- A' E$ Z3 G4 @ return: Z9 G+ ?: ]$ N) h
; Stuff to do when Windows Explorer is open% Y6 a# c( h/ S$ A' B8 T! @2 b
;' Y( V+ ~' A) g& }
#IfWinActive ahk_class ExploreWClass|CabinetWClass# V/ o% r& E1 H5 V8 Z$ E$ v
; open ‘cmd’ in the current directory8 \" q7 W: ~3 w5 I2 \1 s
;
0 A" Y1 A) `7 k5 |( |6 P #c::
' l0 r4 |: F" @! S2 G+ B OpenCmdInCurrent()
& C$ U% R4 i( ]( S2 }* Y return
" O& u4 B0 I+ _, \4 T+ Q. N' V #IfWinActive7 ~9 B) l- U& J* \/ ]
; Opens the command shell ‘cmd’ in the directory browsed in Explorer./ U# g+ u0 j$ Z+ b" F
; Note: expecting to be run when the active window is Explorer.
; c% r& L* L7 @6 b4 m9 W% v0 _ ;
) [2 w, q" |/ j; O5 J0 { OpenCmdInCurrent()& L) u$ b$ G) p2 A8 Y; ?1 H: T1 p, \
{, f% Y5 Z( Q8 E3 X0 Q
; This is required to get the full path of the file from the address bar' _' } i7 i# T
WinGetText, full_path, A
5 x1 `7 D5 X) _% h% i ~ ; Split on newline (`n)9 N; d' `$ C# e6 W
StringSplit, word_array, full_path, `n( }8 @. x6 B8 z! U3 c
; Take the first element from the array/ p: ^. h0 c0 m1 j" v
full_path = %word_array1%
* _! L+ D- J3 u% v; Z5 y: L7 b) Q ; strip to bare address
( I# S& S5 p. K" H* y! a6 S8 l S full_path := RegExReplace(full_path, “地址: “, “”) J; H- [5 e2 q0 t P
; Just in case – remove all carriage returns (`r)
3 y& E0 a# C. P# a9 F StringReplace, full_path, full_path, `r, , all
" [! g" b) n# I6 W1 b' ^ IfInString full_path, \
% \9 v/ }2 B7 y) f {
/ z/ k' E' E+ E' i; U* h Run, cmd /K cd /D “%full_path%”0 X& p8 Z K/ S$ B! {; U) x$ y
}
, X+ P* {6 ?) H8 V2 k else
$ {1 T+ P8 H$ N( l' [# x {
- a! v7 ]2 i1 J$ ]0 t Run, cmd /K cd /D “C:\ ”
( y& Z, t! H) k) A! u }
- y* X- L M4 b5 D. n }* n; l% p# ]0 X- Q1 v% v' h e2 e6 N
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。8 J! K3 V" d5 I% A
这段小代码肯能有两个你需要修改的地方) [& h6 Y0 {$ E2 u
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
+ _# Q& U$ T R* `: v 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
( n5 A: |; `5 B9 B* _* T9 f |