此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
( }0 p& }/ b+ V% i, D- ] 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
- V6 Y4 J- U% t+ ^6 w d- E 方式一:8 I# \1 @! N* m/ E, H! \
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表," T* [5 z5 ^% p! u) m3 V0 _; [
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和# _$ Z! W* ]6 y. u- }
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
6 O, o, h% K4 w9 w- n3 e 方式二:: O0 a" u8 X$ Q7 t6 p
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:. l" j' L: _+ m) {# i
SetTitleMatchMode RegEx
1 ]$ R0 ^ z6 h return( C; s! X! w+ |# O) l9 x
; Stuff to do when Windows Explorer is open
* G0 r3 s, |" `) k- Q. d8 D9 ?% u1 G ;- H* |# |7 B2 V) o# W H2 }
#IfWinActive ahk_class ExploreWClass|CabinetWClass# r4 e( Q+ g8 V. E8 Z/ x y6 J
; open ‘cmd’ in the current directory
4 `! y$ J' Y2 R0 Y5 d) I ;& G4 K4 B7 I+ l$ y
#c::
: C: r# m# k2 o; R; w OpenCmdInCurrent() a$ ^) }$ O3 R g. X) Z/ `6 u, k
return
5 _- _0 ~+ { c9 c- k" k1 s2 V #IfWinActive
5 q( y$ j! ~3 L" ]! I ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.. x/ s- ]( h# i) h) F
; Note: expecting to be run when the active window is Explorer.2 j# n2 I3 I, }8 b7 B, [% j3 M+ }
;
L# ~# e. q; I OpenCmdInCurrent()
* \. J7 E& b1 b& n {
7 V4 {* p$ W1 U/ D! R4 j) O3 d' ^9 z3 j ; This is required to get the full path of the file from the address bar8 P3 {; S G4 I& v* d+ N6 M1 _4 o1 `
WinGetText, full_path, A" e* z4 x# }. E- C
; Split on newline (`n)
: V. v. W$ o+ D; G5 ?9 T! G StringSplit, word_array, full_path, `n8 M0 a% e- z5 ~8 b- ~4 j" q
; Take the first element from the array3 K! W- o- p8 i9 F* m$ I
full_path = %word_array1%. r: U" F8 J1 e2 {# t
; strip to bare address
; T- a& G7 E+ E( J2 Q full_path := RegExReplace(full_path, “地址: “, “”)9 p' ?8 Z- I9 x4 W6 ]# g( z6 Z: T
; Just in case – remove all carriage returns (`r)
N i& K- y4 C8 r! [; C StringReplace, full_path, full_path, `r, , all
, f, R3 K: ]5 K6 l+ M3 M/ ^ IfInString full_path, \ ~) Y$ L3 b* p( q, k, P; g1 |. D* v
{
! g/ z* D. K* W. b Run, cmd /K cd /D “%full_path%”, M) v+ L6 [1 g! e. f
}; E+ i/ ^1 M+ b! _
else3 Y4 h: L1 w: H1 j7 `
{9 Q$ W! u$ P; J( a9 G* c
Run, cmd /K cd /D “C:\ ”2 c! F2 s" `3 \+ r+ G7 {
}
( t/ H \8 r3 t M7 f: H }; g% z$ ?+ E. T8 n! W! o
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
3 w5 P4 y$ Z# C b8 b2 i 这段小代码肯能有两个你需要修改的地方9 y) r0 ?7 l6 c1 I$ E# u( L
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键9 n3 Q0 `1 B$ f. P! G
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “+ y2 N7 t1 [* R; k8 b
|