此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
7 P: X0 I/ h! M8 [3 D 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。. O: R* D3 A# t# w/ R
方式一:1 W$ g. j5 [# n6 G0 ?
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,8 c& o$ Z: `$ o1 e3 a0 Y3 y
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和4 P0 z8 b3 [. `, d! Y# h
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
" u8 G# a% R, Z* M 方式二:: O: I4 _# \' {. x' q) u
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
' e R4 Y9 F7 E6 k' f i SetTitleMatchMode RegEx$ _! r& Y; @$ {. C4 P7 h( a9 r
return& i* G" S5 g9 u
; Stuff to do when Windows Explorer is open' r$ N Q% b- Q9 c
;
- `1 _8 ^5 j# ?( m2 O# T0 R( |6 @ #IfWinActive ahk_class ExploreWClass|CabinetWClass
% l ?- S( t5 i0 l; ~: ]9 R ; open ‘cmd’ in the current directory
9 k& c$ U9 p8 R3 O/ @7 p# ]: C* R9 m/ e ;
: P J# J! V5 P; t% P. ~% L6 x #c::
: c2 h( j/ N, {& m3 c' Q/ V. F. l OpenCmdInCurrent()
1 q9 V( A3 X7 o, E& s return
3 m0 e u' d$ }, ]6 c9 i3 C #IfWinActive
1 ?9 F9 Y, B; B% k# X" {- k ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.5 b4 j, a3 e0 F% z$ J, T
; Note: expecting to be run when the active window is Explorer.
: _0 O1 q* [+ A" ~ ;8 I" [. n( D4 o4 @
OpenCmdInCurrent()& Y5 X% i- Z+ @2 R. {
{
# u/ t, w6 L5 Q, R2 g6 q ; This is required to get the full path of the file from the address bar9 g7 }9 t, f1 ~5 r) N7 R
WinGetText, full_path, A; v' Z1 ?5 A4 b& \5 Q* w i; L
; Split on newline (`n) g4 O' O1 v9 R- l; f
StringSplit, word_array, full_path, `n
: h2 d; m/ L' B6 m9 m' q ; Take the first element from the array
# r% e& |& v. C" O4 m full_path = %word_array1%
+ Q' B; D7 T5 c ; strip to bare address
! c# ^; V0 A; C/ f7 x0 y! u N7 Y5 x full_path := RegExReplace(full_path, “地址: “, “”)( m$ T k1 z9 c8 ~' W$ }% ? \! K
; Just in case – remove all carriage returns (`r)0 L$ Q0 U F6 k7 Y7 B0 A: U
StringReplace, full_path, full_path, `r, , all( w- A- [8 L3 Y0 f
IfInString full_path, \2 Y2 ~- I$ M1 l* \
{& j" T% U9 w# D$ `+ S$ K3 `+ H
Run, cmd /K cd /D “%full_path%”
& _) Y3 H, \( z/ O }" f) c1 b* d6 R! W. R
else
2 g% n/ m; z6 ]& F2 P8 z {( X; X) u' {" o
Run, cmd /K cd /D “C:\ ”$ A- X2 k' j2 j5 {0 B+ k* W
}, N- v+ C- c. d# [( G6 E& p
}; k$ U- J: z/ F% w
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
* U9 h/ {$ k; K 这段小代码肯能有两个你需要修改的地方0 d X# c& X7 Z
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键* r# a+ t9 L* I6 {
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “8 S0 Q8 l5 c3 x; z6 ]
|