此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。; i0 b6 H+ F( u" i& v: ?
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
- {3 ?: V# T% t3 x+ [ 方式一:( Y8 Y u4 @: r$ j4 ]
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
5 W4 U7 `9 J6 u8 n: |4 N1 d 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和1 u1 ~& c) ]$ T1 }. i' I' k
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
j+ v2 s2 r& e7 ` 方式二:
g8 Y y! K2 a' g- B8 } 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:( A; _- w; M2 Z/ U4 x9 b8 @
SetTitleMatchMode RegEx
" s5 O% I/ D$ I1 I# Z9 @ return' U$ M3 u ]. p
; Stuff to do when Windows Explorer is open# t% o$ E$ l# X
;
# @& p, ~0 D! R( E x3 a #IfWinActive ahk_class ExploreWClass|CabinetWClass; a$ {. Z8 j( [' T
; open ‘cmd’ in the current directory
6 c0 t+ G, A( _% M- ~ ;+ @( d5 S4 ^ \' l3 {
#c::
8 b' w/ `' a% I6 o/ G d5 W OpenCmdInCurrent()* J& Y3 J4 l$ }, g5 l0 T( h
return1 Y, o, T4 Q' ^5 c6 }7 z
#IfWinActive' a. K/ }/ n' d( N. s+ w$ n
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
; I+ U; t" x8 U6 `) X+ N1 y% W9 [ ; Note: expecting to be run when the active window is Explorer.; Y+ C/ P2 @( v+ ~
;
8 _' W/ R+ W5 G( _ OpenCmdInCurrent()
( r: m7 ^ Q' \& h# @, ~; k! R( ` {
4 F$ k# ] V$ c5 U! b: |% N' o ; This is required to get the full path of the file from the address bar
. B8 D! u4 N/ a WinGetText, full_path, A1 W/ P/ {1 d. i/ R! I% x
; Split on newline (`n)# h' L5 G6 C6 e! t, M# i' V; H8 m x
StringSplit, word_array, full_path, `n2 I/ w; g: y5 q
; Take the first element from the array4 e' k+ J- W( a! s
full_path = %word_array1%
: ?# X! `) [9 _1 ^3 c ; strip to bare address
4 E% G0 y3 I- Q/ L; v8 Q full_path := RegExReplace(full_path, “地址: “, “”)
1 k0 D* b( V0 Q# w7 [# ? ; Just in case – remove all carriage returns (`r)5 D. E9 L' _, P& ]
StringReplace, full_path, full_path, `r, , all8 x3 p- q' Z8 c$ E* o, o
IfInString full_path, \
p- Z, b! C. m% @: @% Q {0 m( d! V- ?$ N5 I
Run, cmd /K cd /D “%full_path%”
0 e4 k5 [; n, | }
' G7 _$ l. O" q1 u1 d6 J else7 O! n$ ]* N4 t5 B
{; M( y/ u5 p0 w
Run, cmd /K cd /D “C:\ ”
0 M. ~0 e* G2 H" d: c! o }
4 b5 f U3 M9 H0 [8 U; V }
0 w3 I' D/ V, _- z x' u, c 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
) V" R/ J$ C) w1 z6 r$ |) I' O, n 这段小代码肯能有两个你需要修改的地方
: S8 ^% E `9 b) G 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键$ e8 J5 }; B& ~' D2 R
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
" }% U/ p/ E$ x' L$ x |