此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
/ ~+ ?* B) L3 z5 X8 x/ r4 C4 ]: { 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
9 {. z8 f6 \' D8 h4 ` 方式一:
* d! \/ ?) Z- O4 Q 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
1 B* y. V T) D- R! I. t 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和( P1 B7 V. ^, A$ o6 P% A% E6 O) J
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。) s' y6 d- L! ~4 \" A
方式二: f3 g9 S- H: V
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:7 U6 @$ B5 L" T3 R+ J/ z, T2 \
SetTitleMatchMode RegEx! {7 [) }: o I6 `8 e9 E- B
return
+ ~! {: _4 c5 A& e: | ; Stuff to do when Windows Explorer is open
/ s0 B9 Q: z- p3 ^) p% w ;2 d' h# Y) P1 R5 Q
#IfWinActive ahk_class ExploreWClass|CabinetWClass
- ?) @/ a* M A L* v ; open ‘cmd’ in the current directory
& E& K) ]* ]& ~( [/ ^; { ;
* F0 I9 T* A+ ?# K& i0 C #c::+ A# z: I$ N/ [5 S1 Y0 |
OpenCmdInCurrent()
' ?* H% p J6 @ return2 Y ?: d0 x/ m) z
#IfWinActive
6 R# p1 [9 A3 U$ I" X ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.; g* u7 ] o' N: v% u
; Note: expecting to be run when the active window is Explorer.9 i5 e3 J# p$ X4 ~& u3 K1 W: y- D
;% j$ R& r8 N/ `% D0 _
OpenCmdInCurrent()
6 Q8 D9 h! q+ [' q$ k5 R {
: ]& ^9 f9 g" \4 S# s ; This is required to get the full path of the file from the address bar" O) J' D( w7 z8 ~# \
WinGetText, full_path, A
8 T2 @. H4 B; e& _ ; Split on newline (`n)
( n$ K1 B0 J0 @" q s6 i: U1 U; Z StringSplit, word_array, full_path, `n( @3 b6 }; R/ z1 w& e
; Take the first element from the array
- t+ c/ R( C/ N+ b( O full_path = %word_array1%1 D+ v6 Y% ~3 m/ ]2 r+ r/ T
; strip to bare address/ y$ {/ i; u1 y% q R
full_path := RegExReplace(full_path, “地址: “, “”)3 U' W2 Y. q) a# @8 G* k6 H
; Just in case – remove all carriage returns (`r)
* S9 f+ u% L% o! {/ l* h StringReplace, full_path, full_path, `r, , all
# W; ~0 d& ~) g9 Z. T: G IfInString full_path, \5 V2 ^, c7 J& e! d: I
{7 ?. A' ^% g# _6 ^. p5 F3 v
Run, cmd /K cd /D “%full_path%”" F" {5 P1 l, r/ p- n0 h
}/ l4 P; p' W2 S7 Z. u8 W
else
8 {8 R3 Q* I6 w) D1 w* A {
6 A3 {# `% R$ w3 v4 Z: t Run, cmd /K cd /D “C:\ ”
- m* c9 ?/ a' q3 d0 Z }3 \* _( S5 n$ r" T5 q$ `5 M
}
, U/ `& }, j+ K9 y. \) ~ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
# P3 [1 q' B, F6 ~( I( l8 N 这段小代码肯能有两个你需要修改的地方& w# ?0 n: x0 L
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
+ U& p- d6 L2 Q 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
5 A3 ?9 e+ _! w; J) X& ]8 V |