此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。7 K4 e/ Q4 ]- V) N+ w1 k6 [, d
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
4 L! l, v1 i$ T$ n, b 方式一:
! K7 v6 q+ n0 h4 q; H 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,5 l5 z* b: `% s* _3 ]
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和 [" R# M; E: X: A1 ~/ m
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
- m0 w3 v8 h' b 方式二:
* ~8 n6 b: h8 P% b/ q 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:6 e1 n+ k ^* `* O8 T
SetTitleMatchMode RegEx3 Z+ V/ m* |, s1 O, y
return
_! B! f7 r: l' h ; Stuff to do when Windows Explorer is open
. C- R" n! n3 I: Z ;/ z8 U$ w- r3 R1 M% U7 g2 C
#IfWinActive ahk_class ExploreWClass|CabinetWClass) R& y$ ^' }+ [9 B
; open ‘cmd’ in the current directory
+ e: l& Y5 h& Y5 ] ;
; q/ d% |) ^- o: V" q #c::
1 j: A( _+ b# h/ d- v, G OpenCmdInCurrent()
6 s- |0 P F! b9 |4 W$ k# P" F return
x% U7 G. C6 |3 ` #IfWinActive
/ J9 D9 f+ g% F' W( i- | ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
7 o6 n- W' m/ S* _ ; Note: expecting to be run when the active window is Explorer.3 F4 Z2 p* L7 S$ G' a' t$ g
;, y8 |# k- @. ^- h. W7 R: n2 i
OpenCmdInCurrent()
# x4 o$ [% N* h7 i& m& A {
& t8 i; J3 b& r& a* x. m ; This is required to get the full path of the file from the address bar s' y* X5 e& _+ c$ Y& h/ o9 ]9 y
WinGetText, full_path, A: d" Q2 q. d. y5 c
; Split on newline (`n)
0 ^. W' Z; Q$ C% b# K: q, v StringSplit, word_array, full_path, `n& |) O' A( k/ y, p0 G/ y$ `( [# V( y
; Take the first element from the array$ J7 M8 _0 t; S. u- [( R
full_path = %word_array1%# ~! j+ g8 Z9 g! `4 j
; strip to bare address9 o- n: m/ k/ B( E
full_path := RegExReplace(full_path, “地址: “, “”)7 W6 J8 M, g3 R5 m
; Just in case – remove all carriage returns (`r)& U+ d. V! o% [- _7 A2 ]) |/ [5 [
StringReplace, full_path, full_path, `r, , all0 p4 w$ w9 Z W) Z+ `
IfInString full_path, \- J8 b5 Y( j0 E7 F2 P8 G; k" E1 G
{4 B: v6 [) r. |, r. V
Run, cmd /K cd /D “%full_path%”
" O- E' t1 ~+ X c9 \+ h6 A }7 ^$ P2 m' r5 O+ Y9 t
else
' w4 k7 V9 J" { {7 o5 Q( R6 a' @) h. r7 n* D) t8 H# v2 Z
Run, cmd /K cd /D “C:\ ”8 M' ]9 E' j5 h- }6 W
}
9 u0 ~1 r$ t' X8 x& |& A- i7 M }" R( ]+ T7 V7 {% _$ {2 V: n
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。- x% @3 ?/ R- I' C: M
这段小代码肯能有两个你需要修改的地方
6 U+ z2 z( o/ C- M 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
( l; P; [7 ^ |% Z; v; m, H# N4 E6 f 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
$ d4 P/ y5 r1 h( u& v |