此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
. G6 W3 I ]2 E9 k+ u8 B- K8 Z; m 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
1 f0 S2 a% M/ U9 X" O 方式一:8 S; L# Y: R0 ^& o4 N1 U$ X
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
9 ^" M3 C& Y: m7 K$ N$ S) @ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和7 |; N ]! `% T$ Y0 f* f; x; o F
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。- y1 p0 r) r4 ]4 ^
方式二:& `5 \& Y3 d) f! b7 S: i% z
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
# ]0 i5 t; w) x+ D5 H* Y8 Y8 C SetTitleMatchMode RegEx
# W) G" v5 y% B# n# E return
/ h5 F/ I, b0 { ; Stuff to do when Windows Explorer is open
9 T* e( N; o" K, I ;* ~' e, @2 b- Y4 S% m7 Z1 K
#IfWinActive ahk_class ExploreWClass|CabinetWClass2 k( B6 D3 S' Y; T/ R
; open ‘cmd’ in the current directory
" S; L( \1 |9 Z! b ;; b' u5 V, A/ P B1 ^
#c::4 L8 S$ a% ]0 ^; G
OpenCmdInCurrent()
/ f6 [/ W# N2 {% U' P! D0 ^/ Q4 D' { return
; s$ |1 g4 a! @4 G& U #IfWinActive" Y4 V, n s0 i$ m
; Opens the command shell ‘cmd’ in the directory browsed in Explorer. E4 m, r" Y% H& n
; Note: expecting to be run when the active window is Explorer.. o* @4 R4 M0 s5 p9 f
;
# X H8 N F; |: M7 j6 U* z OpenCmdInCurrent()" o8 Q! ^, y* V! ^
{
O3 ]9 r! p0 q2 e$ q/ ?: ` ; This is required to get the full path of the file from the address bar
' c/ f5 f& A; e0 r) x WinGetText, full_path, A3 G# I% `2 k$ W P% S
; Split on newline (`n)
" t3 P3 [+ Z1 F4 f6 R- X% b- g StringSplit, word_array, full_path, `n
% {( k* U) I! i/ n ; Take the first element from the array
) ?5 l. o. F3 n* l0 x' S& J full_path = %word_array1%
1 J: j- V, I' F& R$ ? ; strip to bare address
9 r. Y* u% C* ~8 Q+ f/ O4 H* f full_path := RegExReplace(full_path, “地址: “, “”)2 k: o! E* C9 d4 v4 G; H& E
; Just in case – remove all carriage returns (`r)& T3 i" t/ h' E# G. m
StringReplace, full_path, full_path, `r, , all1 u9 g: g3 r2 B3 n4 j
IfInString full_path, \7 ~; j9 j; h8 F
{
# @# S0 b0 H3 W! h7 \ Run, cmd /K cd /D “%full_path%”
& w" a" p! [! u9 j2 H }! P& x Y% O% t/ T4 a' K: n
else/ t% @7 r2 a, b+ e4 c
{
9 \* e, {& L. a' b: _ Run, cmd /K cd /D “C:\ ”
6 h, @3 `' C4 h# ^, S7 j' S! V }
& Z& {5 b" p7 ], k: b. M1 O } \ {* }- C/ ?
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
$ t6 t: z% F+ m( \( G/ f; A/ e 这段小代码肯能有两个你需要修改的地方
- K e& K4 Q5 |' b ?: s 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
; N$ A; E2 N+ Z" z! e( E 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “9 ^1 |2 y3 B; j8 \ \$ i! s+ H
|