此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
' k! b6 ? Y3 s 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
6 ?8 u: _% I* a$ }' T$ c6 h 方式一:
! ^ o1 T' w, j2 `5 T3 [ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,. |( m+ T* H$ c# s% y
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
% ^8 t+ P( j0 [ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。. P3 D. P" D1 W% h# j! s4 v
方式二:! P* F( X# e* U* G0 z8 g
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
+ C5 W7 p* B0 C. [ SetTitleMatchMode RegEx
2 J0 r; y; z' O* I% u9 b- D return
' y. B. x1 p% n/ ^: @/ Q( B8 C8 c ; Stuff to do when Windows Explorer is open
1 V* S4 _% E* `+ e ;
3 D" w8 j4 w0 W" [ #IfWinActive ahk_class ExploreWClass|CabinetWClass( \& X8 I0 k9 j# }5 W+ e
; open ‘cmd’ in the current directory
# C: V9 y& k- f/ W% @! P ; @4 ^( w' P% m: S/ i9 P2 u3 M7 M
#c::
I& E( j+ O. A/ r h& l OpenCmdInCurrent()& A# ?+ y8 X8 l( b
return
$ h: I6 q) W) [4 c, R #IfWinActive
5 w/ u+ I' h, u2 G# ]1 ? ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
# ^. L( f+ v. k% M7 I8 j" p- u ; Note: expecting to be run when the active window is Explorer.' |7 T, m0 }- Z/ Q
;
- M! _6 c0 ]( Q# R OpenCmdInCurrent()
- w, d, [! r% M7 X; F3 \& \ {$ h% O7 e" e6 X, C w
; This is required to get the full path of the file from the address bar
& {) ]7 \7 @! x: X WinGetText, full_path, A4 f, k. m! X* q. ~& t
; Split on newline (`n)
1 v. a/ v# w1 Q; u1 G5 E StringSplit, word_array, full_path, `n
/ n7 v$ i' {! o9 @, k# C: O: t ; Take the first element from the array0 u a% s. w8 L/ N
full_path = %word_array1%
. B: ^1 f" W, W% _0 ^& _ ; strip to bare address
) L( i. v! r- N& M t full_path := RegExReplace(full_path, “地址: “, “”)2 D* F+ B' j7 P5 ?4 f# }( t
; Just in case – remove all carriage returns (`r)
/ D2 z9 X8 p1 _( X1 q0 K. T5 T+ q StringReplace, full_path, full_path, `r, , all4 n6 S2 h3 `3 q, t- U( w( T
IfInString full_path, \
5 O* C# r: F3 S: ] {
2 v: m5 c2 g' y; l+ W" [' g Run, cmd /K cd /D “%full_path%”" u7 w# D( {+ z
}
" E2 ^) I6 E8 F, ?* ^; u else
7 g+ Z: K% J& H$ o" ^0 B {
/ @% O: }% f# W Run, cmd /K cd /D “C:\ ”
$ A m) K g+ ~$ l/ Q8 J }
, N$ z+ `5 ~( f4 m2 a }
6 C- q' d- H8 n) x- A 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。) a, Y6 x* g9 ?; i% ]. A
这段小代码肯能有两个你需要修改的地方
0 e2 U" d/ K7 u5 q2 f3 g 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键2 A' B4 d+ }0 K; h p$ i3 V. d
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “: `/ ?* c* ?& N
|