此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
( x1 d' b5 z8 E# o! C& a 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。$ j6 K% c& ~% ^
方式一:
% C: [( ]4 k! b) S0 S* H, y 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,+ e" r* |. {# I
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
5 h3 q, y& @2 C1 |4 A HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。/ ?1 u( G+ K' ^% U; \7 {0 v8 M
方式二:: e1 d3 W) {2 u: W) d4 T
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
6 o0 p8 ~" f% u/ e SetTitleMatchMode RegEx9 h' C r5 P/ M* p) B4 y
return
: e' } Z' x' {" \ _5 U ; Stuff to do when Windows Explorer is open
8 }$ V* A- Q- b) z6 |# x- Y ;) b/ q5 C( z7 \+ X8 c3 i9 n
#IfWinActive ahk_class ExploreWClass|CabinetWClass
" w* n1 |- ^4 Y$ I& V+ a9 z9 X ; open ‘cmd’ in the current directory
9 \+ y; s+ B- L+ ~ ;. k$ z' a! Y& ^; }' F: C" z
#c::/ P8 l% I c9 @ V( L* }3 c2 K
OpenCmdInCurrent()8 v7 ~, q% I& L. R
return% M6 G. I% L6 n2 y8 b0 u8 B
#IfWinActive
$ G6 k. |6 T# Z$ a" {: W" @ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
+ g# J3 n$ \- Q ; Note: expecting to be run when the active window is Explorer.2 d5 p3 q" e7 K, Z; @. U3 f
;- u) M8 J& d, @: w; d+ f
OpenCmdInCurrent()+ }4 O- s( ]& n
{
0 A( ~9 a: D8 Z5 O# A ; This is required to get the full path of the file from the address bar; E$ F; v* M/ b' p! V) |1 s
WinGetText, full_path, A) U+ s) c4 G+ l' I
; Split on newline (`n)
9 d. o8 E% e/ X6 J& U StringSplit, word_array, full_path, `n
/ R7 \- T; G t: z ; Take the first element from the array
4 n" |0 R8 }+ ] full_path = %word_array1%: {+ b3 ~: @" D5 S' M3 D( Y
; strip to bare address
4 w$ d0 l! |% } full_path := RegExReplace(full_path, “地址: “, “”)6 B) Y0 w* n1 S0 [! h
; Just in case – remove all carriage returns (`r)
0 y9 H% d- c& D) a8 Y- W4 Z0 L StringReplace, full_path, full_path, `r, , all
* Q3 _8 c: ?4 \% V IfInString full_path, \
$ A% |, k6 _! K% b {
; [% z% A5 w7 t' B# S Run, cmd /K cd /D “%full_path%”
- c' @6 e6 e. s9 P ]0 y; w0 L }
9 s4 T; p7 F3 E& j! a( w8 S else' N9 R A8 u) k' S4 ~6 W1 u
{
) }1 S' a8 z' r$ D# } M# A Run, cmd /K cd /D “C:\ ”
8 E/ x$ V" H7 f1 a |9 a$ a }
9 [; u3 g# @; e9 d5 K }
7 g" e/ A. ?0 c: d: Z+ K5 ~; L i9 z 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
- `/ W: [" V- r/ A1 K5 N0 P9 c 这段小代码肯能有两个你需要修改的地方
5 w: P! c$ M/ r- y 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
& n0 v, u" {5 r" B0 B4 F 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
- G& F r: W) q7 A, B |