此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
( h; h. @. }% l 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。9 @( G5 y; z$ E3 g& a- J* g
方式一:" Z, K. F0 }% T2 p$ C" o
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,9 H' a4 a: C6 j2 n a. U
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
# e! I* f, j: O& i' } HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
" M7 ]! C; R4 }# I: x 方式二:
5 e. \" ]8 u8 q2 B, w$ A 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
0 b/ S5 `3 ~; C SetTitleMatchMode RegEx
, Q( K( m( j# R8 P( {' ? return
2 y4 |% N0 \6 o2 T' Q- _& Y i5 g ; Stuff to do when Windows Explorer is open; v% \6 h: T( ~) t; V& ?6 ^
;
% @8 \' d. S7 n8 M- P4 o #IfWinActive ahk_class ExploreWClass|CabinetWClass
P( V, B- ?5 x1 g/ r" Y6 F& T ; open ‘cmd’ in the current directory
/ c7 _# y8 D: r7 p7 Z4 Q6 b+ F ;* C' m* H7 p0 s" y9 L
#c:: p/ q* W/ s, u
OpenCmdInCurrent(), c: {7 u. O7 }
return, Z' K0 L$ t5 P$ \
#IfWinActive
; a* H, g4 p' ?- I" G ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.8 Y3 K; w, o# h% j F' v
; Note: expecting to be run when the active window is Explorer.6 ?% B. W { n2 J+ L
;. P! d+ Y. G9 G" @& K
OpenCmdInCurrent()
4 l i0 }5 j7 H, C8 N8 E2 K {
- _+ c. n3 k. C- O0 T& a7 s& h ; This is required to get the full path of the file from the address bar
; P" h& ^- b5 e. o* W- ?; v WinGetText, full_path, A
+ Z" f+ q$ ~* B( Q+ K; \/ A9 N ; Split on newline (`n)# p4 v ]+ C$ {4 `
StringSplit, word_array, full_path, `n
8 t" j# t+ U6 u6 W) ]! A ; Take the first element from the array
+ k V% k2 l8 X5 C+ _ full_path = %word_array1%: _( ?6 c8 W. ^! t
; strip to bare address
" @$ d: P9 V& ^ O full_path := RegExReplace(full_path, “地址: “, “”); h8 s% H& ~* H7 `: t5 D
; Just in case – remove all carriage returns (`r) P z3 w9 Y3 }! W
StringReplace, full_path, full_path, `r, , all9 C- F4 k6 q) o4 U V4 q
IfInString full_path, \7 ` R0 T& N; f( y6 \
{0 F" k# Y& E( K! R
Run, cmd /K cd /D “%full_path%”
% A, z! B. m( ?: A9 ^, F0 r- d }
4 |$ n& E7 T! A0 _ else. h, X m) K, B
{4 g+ S: Z1 n' l
Run, cmd /K cd /D “C:\ ”
* P: g% K5 C' i }8 J# d3 p: T( [! M
}* n/ V4 C& R# x
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。: X# G1 z7 M! Z9 d1 V
这段小代码肯能有两个你需要修改的地方" z' _ I, a' x0 V$ s) I; i( l* R: D
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
: c, d @6 j0 u. n$ D 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
2 Y, L t$ s- S1 j |