此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。9 W1 ~! o( X6 Y" Q$ D
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
9 H# K( V) B. P 方式一:9 r( _. }) ]- _' ~2 Y1 D2 ^/ _
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,( E6 D; b1 e ]" A% u
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
8 y2 M! n, i( M HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
5 U) ~5 w' V* I6 }' f 方式二:
2 N9 ~3 o3 d- N& @# w. x 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:/ h5 L: M5 b7 H
SetTitleMatchMode RegEx
! A+ n9 k' V* J# q# L% r return
_( d' G( U }1 V o5 I ; Stuff to do when Windows Explorer is open
2 h1 [4 L; a9 T B2 m1 d! G. C ;
2 o6 A+ R! I# \) T. ^ O3 y #IfWinActive ahk_class ExploreWClass|CabinetWClass
) e7 \% u$ V6 U* H5 x1 z5 R# X, P ; open ‘cmd’ in the current directory
7 d2 I' G) S8 L# Y! q ;5 E' ^" k' z1 h
#c::% P0 r2 F* i: K! P' [
OpenCmdInCurrent()3 m) P4 k) X: c' s0 A6 b# G; p
return: {% \; s* [9 c/ {
#IfWinActive: t3 d1 n; w0 e- b ^6 \2 u
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.2 A9 X6 A7 h& T) b: {* L' y
; Note: expecting to be run when the active window is Explorer.
1 x+ ~" R" {6 m% _1 { ;
+ ? n& d0 D/ T$ b0 H2 m7 f$ o) I OpenCmdInCurrent()
# K# j+ r5 J/ }) \8 G2 ?0 n9 b {
( V9 e# G+ }8 t( I9 G5 J+ a6 Y4 s ; This is required to get the full path of the file from the address bar* b/ @0 \! m$ Y5 N9 i
WinGetText, full_path, A
$ T; u$ G9 n1 a+ y. Y ; Split on newline (`n)' ^7 b( s6 y. e$ x
StringSplit, word_array, full_path, `n
" e; V- q; f, I ; Take the first element from the array7 R4 H( q% K; e P7 d+ z
full_path = %word_array1%, j3 M3 {) k* Q$ m
; strip to bare address3 l; o/ j u/ K' O) p: F
full_path := RegExReplace(full_path, “地址: “, “”)
3 Z; M) l+ ^, h0 k: y' ^. ?1 w2 p ; Just in case – remove all carriage returns (`r)
0 Z5 t% }& b9 e' a, V StringReplace, full_path, full_path, `r, , all
( b1 n- K0 \' H3 W) P7 s: f IfInString full_path, \0 e. x9 a4 Y" g
{7 x. U1 @! ^& \( ~2 L
Run, cmd /K cd /D “%full_path%”
- g" I( ^2 _, k; _ }# j9 V; N1 P% w" g: Y3 w" g. [
else
, T# |8 H/ Y1 c" l {: r% d `0 f0 Q1 X2 G9 S
Run, cmd /K cd /D “C:\ ”
3 B& I$ O6 g! j! O: H" o% q$ `1 ]9 X1 h }
M4 r/ f* t" j) V, H% @6 P }
" p& ^- y. r" K: C {, z( _ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。8 T# X6 w/ ]. \6 H% B9 C
这段小代码肯能有两个你需要修改的地方0 n3 n& w& x2 |" g4 R
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
) H# m9 q: C+ Z4 h6 K( \1 k 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “3 u9 ^" M5 `! I- ]# e8 N: Y
|