此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。9 D8 ~% T0 p2 I, V& w6 S6 H
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
6 z) t Z6 G4 _0 A, M 方式一:8 x7 u/ W: Y ]
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
: Q" q; S1 R0 e$ S9 m 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和- U6 Q) R* m& f u0 x& v) Y9 |% r
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
: ^+ N# w+ p5 h* `. [ 方式二:1 U# k7 T8 {& p7 E$ F) C) H% B2 Z( u
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:% m. d; T) I4 g! r$ Z
SetTitleMatchMode RegEx
4 g( H0 ?$ y& I return: M! w- U- I! e; ?
; Stuff to do when Windows Explorer is open
- r* r z6 \ X% h ;6 U/ B4 k/ e O2 R( Q4 D
#IfWinActive ahk_class ExploreWClass|CabinetWClass+ g8 F, A: D. c1 ^
; open ‘cmd’ in the current directory" V4 [- V% v( K: J: Z
;
+ T% C2 |4 Y$ H2 ]0 J' e #c::
/ M x1 M# p8 x" v8 F OpenCmdInCurrent()
/ w/ c2 t7 N0 t# `2 \+ c return
" v: H0 m- K& x" W \: N #IfWinActive
$ g0 K* G+ s9 O M. z, q ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.+ ^4 c1 U- J+ I. E
; Note: expecting to be run when the active window is Explorer.2 y; w9 [7 x$ q! V5 f1 x
;
$ p* d5 C) l& |( P( I C m1 E OpenCmdInCurrent()! p$ ~6 @+ F9 }- t
{. Y) P* a. S, i0 _
; This is required to get the full path of the file from the address bar
3 e1 y, A( _$ r' Y; F WinGetText, full_path, A
+ c! d2 I3 s( z8 G* J: M ; Split on newline (`n)
; `! K/ `: D4 C+ { StringSplit, word_array, full_path, `n
2 r# W7 F" X# k ; Take the first element from the array! O5 {& c& h' W; @" u2 \' {
full_path = %word_array1%( h0 K. N% W- j3 n" y. _9 T
; strip to bare address- d8 Q1 D" y2 q' K% O: y
full_path := RegExReplace(full_path, “地址: “, “”)" @# P# [6 t! z! t, J. a
; Just in case – remove all carriage returns (`r)
1 b# V) I- H2 a0 D! y8 @8 F StringReplace, full_path, full_path, `r, , all
/ U3 W( c- s" {& I IfInString full_path, \# ^* N, \# s4 v8 G- Q
{
6 M0 ~/ K$ p* Y- F N: s# a$ g# A Run, cmd /K cd /D “%full_path%”' L3 ~2 Q Z4 B
}: q- D: w# v c+ `' X0 i
else2 ^, f9 k5 f+ _+ d# C3 {
{
/ p( V7 G" @9 j, l9 r5 h6 g: j Run, cmd /K cd /D “C:\ ”
- Q B/ T8 M. u" M' { V% m }
* t. [3 Z0 o6 X) m! l! j; N/ n; Y }
- K+ u8 ?' r" i( D( N, o9 [( f; B, {0 q 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
?8 h6 ~( ~& C1 b n" Z 这段小代码肯能有两个你需要修改的地方, W q6 T2 S* w2 @
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
7 ^; L d/ L+ ~, f; M- l 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
( M6 t+ \0 m, w |