此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。" r, r7 g' k5 T
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
B8 |4 W2 I+ v- j9 v; {" V 方式一:
2 n0 L, F, p0 N5 a0 y7 y1 Z 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,% I5 g8 l* e8 T' X3 y' E% v+ b
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
; {- r" e/ h. @+ O" q$ ?4 Y. u6 z HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
$ q2 m% P1 v. \( n; Y3 X- l 方式二:0 v9 l) \9 J# H4 M9 x$ [
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下: D! C' O1 q+ |, p6 B
SetTitleMatchMode RegEx5 e9 g ^! {/ r5 T8 _" G
return0 }+ M$ z. G( V0 |; Z) h
; Stuff to do when Windows Explorer is open4 l1 X8 _# c I; \2 K6 k b
;
7 [9 G5 j( g- _1 B #IfWinActive ahk_class ExploreWClass|CabinetWClass
! V( @1 \' F$ U# I/ I5 a' E ; open ‘cmd’ in the current directory& Z5 v" {! C ?. j4 K+ g+ \$ D3 _
;
; f- o" C: U7 Z' _: T# a #c::7 K2 { p/ K2 C0 l, y" r+ t0 q: b
OpenCmdInCurrent()# ]- i/ Q* J! J5 l
return* s# l) a* s1 s& W
#IfWinActive& @3 W5 @/ F8 o
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.8 A; R I0 ?7 \/ V L
; Note: expecting to be run when the active window is Explorer.
. X5 D O4 S" w5 b9 L7 e ;" B, [3 U# s; [4 Q
OpenCmdInCurrent()
, L" v& X& n2 C- t! \ {
8 {/ y' t) t4 }) H2 v ; This is required to get the full path of the file from the address bar, o( T# M# I% o5 P
WinGetText, full_path, A! W( e( h$ J; |) t
; Split on newline (`n)! T7 T K; x4 }$ h0 W3 V# i
StringSplit, word_array, full_path, `n6 Y6 K* D% {+ P' C
; Take the first element from the array8 r. k z! Q: q% @
full_path = %word_array1%
$ t) n' g A2 ]% F5 g; @8 X1 y ; strip to bare address- S7 y8 I( u9 A6 ~8 t' |
full_path := RegExReplace(full_path, “地址: “, “”)' e! ^$ W! J4 b# j2 |
; Just in case – remove all carriage returns (`r)
+ A( @+ x9 \( ^, O7 Y7 ] StringReplace, full_path, full_path, `r, , all
* r& E5 w; o+ g7 `" G IfInString full_path, \% |) p5 m; Q) k' g/ G* o
{) m" K' p1 e* f g; H
Run, cmd /K cd /D “%full_path%”7 G4 K4 x/ ^3 U
}* w9 m/ K ?' ^) M( k
else
2 ^( j4 _! R9 ^: L! A5 Y& R {
5 _+ r$ T! }" U$ c9 w Run, cmd /K cd /D “C:\ ”
. e' H! G0 R, ?' u6 \- D9 S }
5 i/ {! o- }; j0 ]4 x }5 N1 S3 M* Y* y9 d
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。6 W$ a+ @8 K4 F* x) G3 [, f5 C
这段小代码肯能有两个你需要修改的地方
: H9 f9 i! e4 i 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键- ]! S7 V, F! N" B7 c+ `1 L
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
! ?) P/ {- L- f, A9 Y7 s" L |