此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。4 Z7 b; |; X9 O* }/ G! p6 Z2 A
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。5 m7 [6 D+ W) G- o4 E) v8 W
方式一:
1 t, u4 A4 L3 D- ~! b1 F0 s6 w, F5 h1 z! ] 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
# H! r0 B+ S( @$ z 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
; ~) _* V9 G* |: D* ` HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
/ ]- ?% O& j: O4 z3 }# p B 方式二:( W5 R8 a; e9 t9 g6 P
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
( e s9 J! y! k+ O+ }; } SetTitleMatchMode RegEx
, Y1 m! z+ g) v5 C4 D return
5 j) U( K- K* k ; Stuff to do when Windows Explorer is open
9 r1 U2 H( u2 H. P/ x ;; H [) ~. T( k$ y4 I# P) E
#IfWinActive ahk_class ExploreWClass|CabinetWClass
1 q% b* ]( R9 w+ Z H/ A ; open ‘cmd’ in the current directory3 _) L m. I l% V: z
;% f) b6 z* ?1 W3 n
#c::% s( W6 c1 m: D# I4 f
OpenCmdInCurrent()
' v7 c' p) t0 i# R7 F" \7 g. g return
2 ^: d+ V; M; b0 ?3 g8 D #IfWinActive
5 L, O C: E9 Z6 U: W ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
# @0 m' H) ^0 _ X8 r: P ; Note: expecting to be run when the active window is Explorer.
! p7 e# |% \4 @4 P9 K& N4 {) U ;
# R5 `! f( c# Z3 L+ u OpenCmdInCurrent()
8 E- L3 G' X# A3 n+ B3 K5 M {8 z; A( z3 _( W8 J' J5 S
; This is required to get the full path of the file from the address bar1 g9 m7 v8 M: h
WinGetText, full_path, A( q/ k4 b* R3 f
; Split on newline (`n)
2 l" Y% X4 ?1 w StringSplit, word_array, full_path, `n
" ?) z; K; P% u7 r# k ; Take the first element from the array
8 P1 V5 P% i* D full_path = %word_array1%
# F& I6 W% f! V# z. N6 g ; strip to bare address
2 K2 V8 s1 F/ [ full_path := RegExReplace(full_path, “地址: “, “”)* W$ t i! N9 b! L4 n3 |6 J9 Q
; Just in case – remove all carriage returns (`r); X7 z. {8 ?4 J% o7 R
StringReplace, full_path, full_path, `r, , all9 s$ |- r E3 l" J& m! r
IfInString full_path, \
+ f2 h3 ^% C' s4 E( R, X' U {
# b5 Z# S. b* }: j. u Run, cmd /K cd /D “%full_path%”7 e! g7 W2 K K7 O
}/ c3 D% P% T, s0 @6 b, Y+ t
else" B" H# T: J; l, B+ e
{
( e. H {7 n/ h$ T0 A Run, cmd /K cd /D “C:\ ”
# B# ] }0 R+ ]# g+ W7 s" w' l8 i }* \0 c$ P: R" R- ]
}
3 r7 n7 C C: f& t 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
2 g1 Y9 Q1 i3 i, y" d U 这段小代码肯能有两个你需要修改的地方
5 ~3 S3 f+ Y% M, D& m: w! X) T 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键$ `7 [3 F; N( Y6 ]
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “1 E2 K1 Y& P+ e9 J+ `7 V) a
|