此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。% P' I4 \# ?' A6 J+ g( f
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
3 U+ K) z" h' D4 y/ G. i 方式一:+ @8 ]. g" J" Y9 ]
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表, \! I* }% D' ^3 c, Z# y
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
6 l' U. c1 s& C/ t HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。+ B3 a: `- P- d8 o. M% l) }0 y8 d
方式二:
: J6 c2 ~+ n) \, g 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
+ s* [* Z+ K0 N( _- `' O SetTitleMatchMode RegEx8 i9 W* b3 ~+ x' q4 N
return
- Z' A6 _, K; b; }. b! h ; Stuff to do when Windows Explorer is open
& r- K, L; ]7 t4 k# [$ F6 S ;; J3 \/ X8 \6 I. l% z6 `! g% h0 K
#IfWinActive ahk_class ExploreWClass|CabinetWClass0 O' O' D0 v d$ {2 _$ G, I
; open ‘cmd’ in the current directory
+ x- ] h9 _# |) W ;3 A5 g: ~0 } u- h2 {
#c::
+ e) t5 n4 ^% k/ p OpenCmdInCurrent()" _0 d% O5 y2 E1 q- o) [$ o
return6 o9 f9 `3 Q( s' f
#IfWinActive. j; l! Q$ g/ ~6 q( ]
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.0 j" z" p- {! b, w; s8 I: _
; Note: expecting to be run when the active window is Explorer.
/ q, ?. i4 u/ A8 Z' l ;! N9 m; h/ H) K6 A. @& A
OpenCmdInCurrent()
) ]5 i p! T% K- x {
- ]: j" S! W0 O4 @7 V ; This is required to get the full path of the file from the address bar
- {7 W; \7 |; x: L y& E; B# ` WinGetText, full_path, A! W" S/ _6 h7 V
; Split on newline (`n)
: t; m5 J/ A- ]4 s8 g StringSplit, word_array, full_path, `n
, s U/ s7 t. T ; Take the first element from the array
# \1 t% W; l- ` full_path = %word_array1%
/ m" u0 h: R0 {0 E ; strip to bare address
- |' I4 ^$ ^1 D1 C full_path := RegExReplace(full_path, “地址: “, “”)- @5 t2 j# U& c9 `
; Just in case – remove all carriage returns (`r)- V6 b. k; M2 l$ Y
StringReplace, full_path, full_path, `r, , all
# h/ V: p$ F+ ~5 `6 u- L* k IfInString full_path, \
( A: r8 W' {" ~2 e7 F1 G( ]: R {
, }; ?2 E; W7 ^7 t l* a Run, cmd /K cd /D “%full_path%”
1 G6 L7 \, Z; `7 d8 a# M) E! q! F. s }; v6 L, k C+ }( a
else* O' B' p1 l9 k- ?2 V
{+ `. p) o# `" w2 _
Run, cmd /K cd /D “C:\ ”
" c, S, Y1 r$ {/ ^0 \. Z }! X+ H( K6 d3 N/ O K
}8 \; l) K$ q- V' o
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。! A+ U( x u$ A U! M
这段小代码肯能有两个你需要修改的地方
t- n" P" b4 |) I4 w. M 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键3 t2 o6 G7 b4 U- v/ |
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “' E" g5 ~. g: a0 Z% i! [# n
|