此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。/ E5 d# P6 b/ b: `" O4 V
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
; q; |6 ~, @* T& N2 w( P8 O1 |6 ~ 方式一:
" U, @; m( y! Q2 A 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表, ~7 l: F" L G6 [1 Z- E
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和0 J, A# _" f g
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
: H' B: T6 x8 Y. f6 X 方式二:
, E: c' E) R# W/ M 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:& b) {6 c! c; a( H
SetTitleMatchMode RegEx3 c& | B/ z9 N Z
return( o$ n7 i8 Y- m$ e1 i8 Q
; Stuff to do when Windows Explorer is open
9 w9 U& A- i, G/ l5 v$ {) F ;
8 W) a' n/ q; r- T3 b( O! p' ?# r #IfWinActive ahk_class ExploreWClass|CabinetWClass
& o) u. E8 C0 l0 ~7 C ; open ‘cmd’ in the current directory
/ {' Z3 ^2 u/ S: K7 U1 u+ ?9 m- U8 l ;
- V8 ^( T% ?6 a7 W6 S #c::4 T) M0 H$ J' R2 ^4 c' q
OpenCmdInCurrent()! s/ P' `6 D7 [. n4 E. q. T3 K
return* j# U! j7 o( d0 E/ Q& q% G5 z
#IfWinActive
; ]1 D2 l+ x% |! C. d& o! v ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
% G4 g6 X1 a- O- [( q$ D6 C/ o ; Note: expecting to be run when the active window is Explorer.
" f% N% r6 c( O8 f( t# ` ;* y0 q& }* d$ [3 U8 J
OpenCmdInCurrent()
8 @3 A7 A; X$ q1 @) R' p% t/ I {* f: _9 Z; g4 L# \
; This is required to get the full path of the file from the address bar
% Q2 R# ]9 ^1 K0 J9 y( T WinGetText, full_path, A- ?' K) `4 j( j" x$ u
; Split on newline (`n). G4 i+ L/ l9 E: {
StringSplit, word_array, full_path, `n
# I; e, w* c5 j" v/ }- h ; Take the first element from the array
8 _7 @" q9 a% ^ h9 j. a full_path = %word_array1%( r/ W6 l3 _& c9 m" R9 W6 z
; strip to bare address. O" ^9 o% T( k% u
full_path := RegExReplace(full_path, “地址: “, “”)
* @( V) W4 v& l5 j9 B1 L c ; Just in case – remove all carriage returns (`r)% w5 A5 U, k w/ F0 u% p
StringReplace, full_path, full_path, `r, , all. C% R3 M8 Q& g& X D
IfInString full_path, \
8 I: W# s+ F9 }! [7 U! @6 ~5 Y {, f' l+ [7 r4 Y8 U# A. ?, V
Run, cmd /K cd /D “%full_path%”
& O# L$ c9 `" ~) V `8 S }
2 w, E+ h8 i+ s3 z else
, g4 S m, S( X# R% P! G9 E {& d, ~ A4 {, I9 V: D
Run, cmd /K cd /D “C:\ ”
s- }" i& A1 U2 d" q2 }, X2 v }( ~' g) k S$ g2 |- `+ m3 R
}8 I5 E* G3 Y; {1 {
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
4 A0 U' d- R1 n8 o( E3 w1 b 这段小代码肯能有两个你需要修改的地方' `! m8 a, ^/ M2 ]* D5 ^- y L! u- @0 ~
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
1 y! }" c2 L& R+ J. \ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “* P! U( i* Q4 v' E
|