此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
+ N# Y7 v c& O 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。 N1 j9 M* E; s$ r& a
方式一:
, a; K6 E6 l/ M, t2 Y5 @$ J) v 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,$ u# y" P: ?3 m+ g8 ?" ~
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
2 q; Z) K( P3 d) w" W* T/ g HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
) K0 G5 L" E' w! r0 o8 t0 E0 E: Y 方式二:3 |! o* p; O |* d
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
* t! k7 Y) ?7 N- y4 ]9 j" J3 I# b* x SetTitleMatchMode RegEx
8 }6 P: c1 O9 B$ e+ q. y/ f' c return
- y( x1 f$ E8 ^9 W* {! H ; Stuff to do when Windows Explorer is open
6 y4 I4 J8 t! }, x) q4 V5 L2 @ ;) S1 w$ r" _* Q$ ~* z- _- n" z+ |
#IfWinActive ahk_class ExploreWClass|CabinetWClass
" z! t% S$ k8 U ; open ‘cmd’ in the current directory
* E7 k6 O x( F+ I5 j6 N ;
4 ^/ h2 S( W4 f. B ~( _ #c::- P8 P- [# u+ I
OpenCmdInCurrent()
9 I$ |1 \5 I# O% b/ T t return @: \) K+ W, }5 P4 c- P$ l
#IfWinActive: S1 a# E L# e% t
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
$ `7 w& G) X" w+ ]0 }3 b ; Note: expecting to be run when the active window is Explorer.0 Q" R5 X- k8 |1 n. X5 p4 q( Q- ?% b
;
]( g5 P1 d: [2 N OpenCmdInCurrent(): m: K. \2 b: H# Y8 A! _9 B
{
' Q! b5 Q" U' D; T2 j ; This is required to get the full path of the file from the address bar, U* B# q3 y% V2 h" H( E
WinGetText, full_path, A
" @$ ?1 Q) R9 Z* A# ~ ; Split on newline (`n)
J+ d0 z- w3 r; N( h3 I% w StringSplit, word_array, full_path, `n8 i/ L+ ?" ]4 h& f _
; Take the first element from the array; B5 J/ x' N. v. q9 t
full_path = %word_array1%: X( W1 l L4 W
; strip to bare address6 m0 {7 B( i& z8 S7 @) B
full_path := RegExReplace(full_path, “地址: “, “”)- I1 s+ [3 o( r( q _
; Just in case – remove all carriage returns (`r)
* |" E0 F# g) F% j" y1 T! c StringReplace, full_path, full_path, `r, , all: z; w+ V# ] `* o2 y+ k
IfInString full_path, \' }+ `/ O" K/ a6 ]$ h8 N
{1 H9 h7 f [) X- [8 B" q" }( r' S# y
Run, cmd /K cd /D “%full_path%”
" S& ?3 `) Q l. t) L% b5 c }
1 Q8 U6 c5 G6 v- C; D else
7 x9 a' T4 q# Y2 u' g6 X3 B {+ K$ l7 ?4 m5 A! B$ Q# F E
Run, cmd /K cd /D “C:\ ”
9 Y/ q) l. t G( W6 A }( Z+ b0 P& \" Z/ A* Z; D$ a2 k
}
( e* b' q. F/ N9 Z- `) ? 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。/ C1 s1 l" A3 D4 g9 a
这段小代码肯能有两个你需要修改的地方, Y4 J0 h' w/ i9 r- J, u
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
' c* l- d9 Q& n* t f4 _ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
% f: h8 K; g, k4 q7 K |