此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
% z$ G" r5 x+ }9 l4 Y' v# q. h 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。/ B+ C* E/ i* X( k$ W
方式一:
* B1 }% c. d" \$ e6 U( U 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
$ \7 r. o' g' Y9 L+ M* c' b7 ]5 a 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和! z6 N0 `7 K5 k! N* a/ ?
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
7 N9 k( T9 D+ G/ } 方式二:
* l! m% S! D$ S" v, n 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
) F7 O- `" e2 u5 U | SetTitleMatchMode RegEx
0 ^: x6 J& I- Y return' G" K- u# [0 `9 O1 M: n
; Stuff to do when Windows Explorer is open( H# {! K D, }' G2 x
;
6 z0 t; @# D- B' B! ?* S+ h7 i+ N2 J #IfWinActive ahk_class ExploreWClass|CabinetWClass
; C+ b$ L8 H& o ; open ‘cmd’ in the current directory
, }9 E! V' i$ [8 C: ^ G ;
2 V$ O5 v6 n0 l$ u. [ #c::: _9 y% d2 w1 O5 B5 c0 n2 o" s
OpenCmdInCurrent(); R8 P* a$ j) K8 P' [: v
return
. s s9 z; }* J #IfWinActive
, p* H7 C+ i' g5 G+ z r ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.5 G0 F+ ~! ]* Y7 ~: t
; Note: expecting to be run when the active window is Explorer.
0 i+ n/ C9 L/ s( J) C! I7 z" Q ;
8 F2 D$ V; P {( i: C7 Y" y1 h# } OpenCmdInCurrent()
3 L$ |- L6 D7 m) x1 H {
5 N; X+ P" c. M5 o) ?! { ; This is required to get the full path of the file from the address bar
; y# s) T. H( L8 j! K( t5 { WinGetText, full_path, A
( ~; T" F+ V& S4 o6 t. F ; Split on newline (`n) x' J! D* l% x
StringSplit, word_array, full_path, `n8 c4 c' h0 }, K) E
; Take the first element from the array
: x! `2 Y- ]( w" X# X/ m full_path = %word_array1%4 d/ V6 W8 u% H9 R, l
; strip to bare address
, V6 T$ @6 i0 x- V full_path := RegExReplace(full_path, “地址: “, “”)% C$ x. H- _; X: u: R
; Just in case – remove all carriage returns (`r)
% x1 c2 z+ _ S+ n/ G( A$ ? StringReplace, full_path, full_path, `r, , all) [( |6 B: w* {0 O- z8 w
IfInString full_path, \; B) Z2 b8 h' K
{
' j) Q f M- i% e0 } Run, cmd /K cd /D “%full_path%”: ]4 R+ k+ c5 [/ o7 j# V
}
& p. B* h/ w9 p; J( L3 N$ p* B0 n else
7 ^+ E5 [2 N% l$ f" p; k2 S+ g {
7 w7 Q0 Z# @- F j Run, cmd /K cd /D “C:\ ”
1 p1 I) |$ d; h3 [& T3 R }
. ~5 ^! p2 V- W! v }
" ^" G6 w0 x) h, Y8 \3 W, m 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。+ D. z. f) @7 I
这段小代码肯能有两个你需要修改的地方4 T( ]7 j# p, {. ~) T* l
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键; u7 |2 m& D5 G/ J* c
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “% y) D( I" f- {0 G
|