此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。( r. S" }: O3 y
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
- ~+ Q& K/ D) P. g, T& X 方式一:
" M, X( W% p; u( E9 [# m; @# ~ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
- R) j5 E3 U/ p9 x+ n 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和3 J* S: R- \" ? x
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。, v' s! l& N0 }- g, i
方式二:- B8 Y* ?# y# }& V
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
; t/ p5 j0 J3 {8 t S* I SetTitleMatchMode RegEx
8 U3 W+ l6 i4 D return/ h7 j" R( w% d" z( ~5 E2 r
; Stuff to do when Windows Explorer is open
8 u# P5 x& }& c' e+ m ;
0 w2 y& {" e% @2 q, v6 W' U #IfWinActive ahk_class ExploreWClass|CabinetWClass3 Y9 n; B. ` d) d" h
; open ‘cmd’ in the current directory" ^. K' E8 U9 V2 r& A- z
;" c# ~! h0 o+ W* B& K
#c::" o @/ n( a6 R% P' T
OpenCmdInCurrent()
" ^. @% Y# @) Z o) v! M: B: ?1 u return
" F# J, I6 Z8 j- M. E #IfWinActive
3 @4 B, g, {; p0 M p# u: s ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
6 Q) \2 Q2 H' ? ; Note: expecting to be run when the active window is Explorer.
: i! s3 n1 b! [ ^ ;
' r, R) Q- ~, M, u% I% [- l1 o OpenCmdInCurrent()
* g0 Y* r" W" H2 K$ e {
8 a% h6 A! ]1 A. m- V* z ; This is required to get the full path of the file from the address bar
1 ~. s6 R( r7 M9 t* \; g# ^7 M WinGetText, full_path, A* P! m N, x. R4 C3 b
; Split on newline (`n)6 I4 O) C" A9 _0 [7 i: Y1 p
StringSplit, word_array, full_path, `n6 s9 s8 X! K; l
; Take the first element from the array
0 N) i" p: _/ j2 f$ W2 ` full_path = %word_array1%- H2 y: n$ |5 ~7 m* x
; strip to bare address1 x y: \, ]) V) ~9 J
full_path := RegExReplace(full_path, “地址: “, “”)! z- A% E4 o; P. T( O' b
; Just in case – remove all carriage returns (`r)/ a) |6 @' E3 `: r' ^- y: {# T
StringReplace, full_path, full_path, `r, , all
' N( ?0 f: X0 a. g5 q IfInString full_path, \, `% D2 ]7 p8 y
{
8 P8 \# G$ p( _ Run, cmd /K cd /D “%full_path%”
2 \+ e P. I1 b; ?0 |) p6 {3 @ }1 b: M3 d! ^4 q3 m9 K5 O7 x
else! b# D( R9 E; b9 N) X
{
* q3 o) e: ~3 K d, T3 k7 `' g6 X Run, cmd /K cd /D “C:\ ”' r8 y( [* W6 p6 {
}; F& f' E; S' U7 O$ k
}
; A: I* c ]+ w 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
3 {# w8 Q; t0 [0 D) |! T 这段小代码肯能有两个你需要修改的地方
2 |9 D+ c' R0 a) H4 i& n 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键4 h2 x9 T: O- W
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “4 e! I% l3 a2 ] u" e4 a
|