此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。& p9 t7 ~# J* e7 P" y- f
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。2 ]( k' w2 O% V1 G9 w
方式一:" k, i/ }3 q: N2 @
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表, [! J" i2 Z# J: m: t W: M- r* @$ _3 H. u
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和! i! z4 f$ @# z$ \. v
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。; ~# r8 u @# ?& y* z
方式二:
+ F# V- o9 N: A' q 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
N) s' U$ j+ q' _# o' C8 y0 g | SetTitleMatchMode RegEx4 S& ^* V$ C8 e" M* K
return
5 D$ `& n/ Z$ S4 \. v' H ; Stuff to do when Windows Explorer is open
+ R D% a F& H* T ;( N" l5 U; Z& Q. {
#IfWinActive ahk_class ExploreWClass|CabinetWClass# L0 y/ d7 b. E4 \
; open ‘cmd’ in the current directory0 H, F# E& H+ L) i. H; h4 W/ u
;' `( t9 p- j# r0 f
#c::
0 K; C% r q" j4 c0 q/ [6 R OpenCmdInCurrent()
+ p% i$ M+ K: _9 [& }. Q return N( `8 i. i$ l A
#IfWinActive
0 e$ e6 D. j4 X& O ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
1 X& v4 d% p3 Q6 v7 f ; Note: expecting to be run when the active window is Explorer.+ I$ i# m# u9 a( ]8 G K- K8 |
;/ z+ M) ^6 c* }) l4 [
OpenCmdInCurrent()7 Q# u, G8 B4 u* _
{, e$ f" X6 G6 Y
; This is required to get the full path of the file from the address bar
- U ~' r8 n# {) C) j7 t4 l9 f WinGetText, full_path, A
1 A8 V+ Y+ H* _& ^ Q! v1 e ; Split on newline (`n). u2 i: @9 k/ ^; e% E3 J6 ?
StringSplit, word_array, full_path, `n
4 g: j. e9 b! i9 |' m8 l ; Take the first element from the array; o- V: b3 O$ c7 q
full_path = %word_array1%3 W; K& x+ ]2 t7 F4 I
; strip to bare address) @- T5 W/ z8 T; }7 Y, {
full_path := RegExReplace(full_path, “地址: “, “”)# d: M9 P& S: t7 w- d* O y: }7 F( z
; Just in case – remove all carriage returns (`r)3 z( Z/ |/ {5 k& E
StringReplace, full_path, full_path, `r, , all/ B6 U7 X# J8 n# Y/ _/ _: h
IfInString full_path, \8 b: v# z& i/ m/ U# R
{( Q7 x6 d% E/ m. T1 p G; @1 S8 j1 q
Run, cmd /K cd /D “%full_path%” j& h j+ Y. K4 d) B
}
+ `5 v& r- s' i: r2 h else- D, S: @0 ~8 ?5 q- D
{) y$ f( e# v3 Q0 M1 n6 r* y
Run, cmd /K cd /D “C:\ ”
9 g! B4 d! C/ H, ? }
* l6 g7 Y: N c0 @. y( N }/ F9 d9 s5 I$ \% i3 N! d! M
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。6 J- ^1 ^6 k% @* Y
这段小代码肯能有两个你需要修改的地方
4 A; t' c; b1 f) @9 \" U 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键/ c4 d/ \. {7 C$ p$ P( }% M
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “+ ^- @$ M; }) r- r$ ?
|