此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。: [' _- W( f* j
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
0 m5 P' V( w2 m7 N- U5 H" w. c t 方式一:- r6 e# ]1 i( ~8 Y) x5 f/ y
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
P1 n% S7 C7 ` ? 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
2 i: x2 d: e4 ` HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。& {- b9 y1 h+ q8 M( V& w3 Z) |
方式二:
5 D& X: `. |7 G7 {) X 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
' W. F0 q/ d& ` SetTitleMatchMode RegEx5 W( u; }% n# C% @5 A% s- D% ?
return9 J$ V! c" E$ g
; Stuff to do when Windows Explorer is open
9 ] P7 o( F0 z6 i: ^7 J ;
B( Z/ S9 X7 Y' \. y #IfWinActive ahk_class ExploreWClass|CabinetWClass
$ p1 b l) ~& y2 _# I4 W ; open ‘cmd’ in the current directory
/ D }( l3 ~8 n! l% C: B$ [; ~# p ;
0 a$ \& J3 u2 Y! `# r #c::
, x1 Y+ Q- R) \2 Q! y5 v OpenCmdInCurrent()% I. ], p1 T: t5 z8 Y
return# I1 O; f- y; Y1 T( `* ^3 G1 V4 d' h
#IfWinActive/ L$ c9 V. i# {+ @
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
1 b- x. N$ S' v ; Note: expecting to be run when the active window is Explorer.
' q0 S! V6 \" g8 t9 { ;
0 d5 n' C5 _0 d$ a OpenCmdInCurrent()) c) U- M- [# h) _* q. ~) } B, x
{( C" w) }6 u- N0 J9 C
; This is required to get the full path of the file from the address bar
4 P% m" g2 @7 ~" n5 ]9 C WinGetText, full_path, A
# ^& c0 \, V5 J9 s, |3 o ; Split on newline (`n): U: X. r" p* @7 S4 f0 [
StringSplit, word_array, full_path, `n
3 S3 f( j3 a6 ~; w) P' A ; Take the first element from the array t8 p V& t# ]
full_path = %word_array1%6 Q$ k: M( [' a: v' X
; strip to bare address
" \$ p( V* B; q0 v$ t! ^ full_path := RegExReplace(full_path, “地址: “, “”)
2 r7 T( g4 V+ H9 M- i% W: F ; Just in case – remove all carriage returns (`r)
) m5 z- e: \' {3 W$ u StringReplace, full_path, full_path, `r, , all" Z' p1 m" S9 v0 K8 [6 ]# j" \
IfInString full_path, \ e5 T/ V* ^7 a
{ w* k: i/ b6 X2 z6 x
Run, cmd /K cd /D “%full_path%”& ^. q- J) ?$ s: {- `
}# V% I4 r( ^3 H+ [ @: R" ?
else
2 f' e6 j( b) d+ j/ f" C f6 W# ? {
/ v) v3 r% l! F N$ `0 H Run, cmd /K cd /D “C:\ ”
0 T! Z/ x9 z4 m$ r' \2 T1 b& Y }% z8 ~$ T; n/ n. P- X' b
}8 O' A5 h7 Y3 g2 M/ J) G* V- U
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。' t e2 S0 `9 Q9 m7 @
这段小代码肯能有两个你需要修改的地方( ^# o; Y* x* B+ E2 B
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
% Y1 F2 P9 n8 d+ y/ R" d5 T; t 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “+ j+ B l/ ?; A) V2 H" B4 i
|