此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。6 N) l& C0 g% [
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
/ m2 X8 B# G& Q9 N- ]2 K* r& K/ T1 y 方式一:8 A, {( e, R: v @: Y
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
% n3 A: z7 U' E% h, U6 W$ _# v) w 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和 L6 z2 o9 Z: u. y3 ?4 g+ v# T
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
" {6 Q$ b* R3 F2 u7 x6 Z 方式二:( b# K( l; F0 |3 Y2 p; s
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:4 c# Y0 M* G: y8 P/ N& w
SetTitleMatchMode RegEx
1 U9 b$ T) p! j9 x$ e( ~ return
& o A3 A; _, o5 U ; Stuff to do when Windows Explorer is open, z7 v* X ?0 U4 B
;
' \$ Z8 [- u1 r! N0 p0 V$ v #IfWinActive ahk_class ExploreWClass|CabinetWClass
8 H) R" {6 q4 U5 e/ s: c2 [ ; open ‘cmd’ in the current directory
! T- K/ ]( ~& k+ R, E ;, y j4 c# Q% v; A0 m1 B
#c::, L& b( s' v( P8 H
OpenCmdInCurrent()4 l) i: B6 S) H: u4 n+ k6 r1 K M
return# }( _& L- T- ]; Z" p0 p; P7 Q
#IfWinActive; W' w% N/ R- c5 |
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.5 M" Z7 V$ q+ `, @2 S+ P4 `
; Note: expecting to be run when the active window is Explorer.- `5 u2 ?. B# `1 q. Q$ c' J% Y
;, ]) I8 P% q; t( V
OpenCmdInCurrent()
! P3 w J; C* h {
/ y& w/ x* ^4 q ; This is required to get the full path of the file from the address bar
" r. z" @$ Y' h1 M WinGetText, full_path, A J6 g" x; W2 ]- }4 ~
; Split on newline (`n)
( a7 z& m% }$ F9 Y: U StringSplit, word_array, full_path, `n
* _8 x# a( x6 h7 ?) ~# ?9 A9 Z ; Take the first element from the array( {% y6 W- q5 J3 ]
full_path = %word_array1%& u% V+ l$ C, N6 [3 c, b
; strip to bare address
2 p, j, h8 S0 h2 i* s9 M' Y* a* w full_path := RegExReplace(full_path, “地址: “, “”)$ r" P/ b1 v& Z m- |
; Just in case – remove all carriage returns (`r), q. ^0 |. v- O% u1 ^
StringReplace, full_path, full_path, `r, , all
; E+ g" O7 ~( r IfInString full_path, \- U& [2 Y8 q C" C0 O1 F. b
{
( \1 A# H( u$ Y+ v! h; E Run, cmd /K cd /D “%full_path%”
; X, @4 |5 U, s0 x$ |1 Q" c }
3 e1 ^' o. P+ ?. Y+ }+ C. [9 f" e else0 q) B$ @' H6 H- a
{' _0 x+ A/ S! J4 t' ]; z# a- U( l
Run, cmd /K cd /D “C:\ ”
8 C% k# S0 ]6 n. T, B+ f }; b2 {' F& W( b7 d: C
}* B/ t$ x) {$ |' x( e
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
& R) F% l# s: X+ o* \3 r* k$ } 这段小代码肯能有两个你需要修改的地方
' N9 d) D4 L' ?# `/ Z 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键9 e# }; q* N; q+ N& a& N/ c
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “* [0 S* e! I- h5 b, S
|