此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。# [( b3 u, o9 c- {
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。" Y( f+ ]+ w: G. Y5 Q) m
方式一:
, I7 Q5 L6 W+ J7 o 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,( B6 ~" p' S) z( ]
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和8 ]* `1 }' x0 h* s
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。( m. B' H7 [# d1 O, E
方式二:) y2 J5 F$ y) S! d5 @0 A" Q0 z
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
^% I1 v- p! ? SetTitleMatchMode RegEx% ~* M) g/ \; B+ g/ \% G) T
return9 T# T/ c0 h$ i) |& O" a1 c( i/ p
; Stuff to do when Windows Explorer is open: ], j. W5 o4 R! G) Y' l* m
;+ ^2 i1 T* [5 C" T) E
#IfWinActive ahk_class ExploreWClass|CabinetWClass
: m6 J( s4 u4 |. A5 ~% B& Y ; open ‘cmd’ in the current directory& A2 J2 I9 i3 j
;4 p/ q% s0 M y6 A: E) R0 k
#c::/ w7 `) n' _4 A+ [. Q5 r# ^6 e! B
OpenCmdInCurrent()
8 L- O' D6 s6 h# S* W: u return
, ], U9 h- ~ f% a0 O #IfWinActive% ]+ }0 G- ~! g6 t" |
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.. ^' \# o( G( R. k/ ]
; Note: expecting to be run when the active window is Explorer.5 p1 }. e/ z" `7 Q# C; c3 y
;7 `- Z. G S: o( ?5 a
OpenCmdInCurrent()
" k6 D: S7 _+ @' j& m {1 Q4 v3 u5 M5 u
; This is required to get the full path of the file from the address bar9 C/ m$ X! u$ G/ d* \9 |" v) D
WinGetText, full_path, A/ a: ?# }& A7 t5 y/ _. w3 s
; Split on newline (`n)
7 w8 ]. I e* K: @ StringSplit, word_array, full_path, `n
3 T4 u" }8 ?' v' {2 x4 \ ; Take the first element from the array# z# Y* u4 w7 c: B8 S+ P
full_path = %word_array1%7 z- ^+ k' @! r/ q
; strip to bare address7 N, U; J- G! @7 x
full_path := RegExReplace(full_path, “地址: “, “”)% M. V7 k: r5 H1 z5 e. N+ \7 u3 x
; Just in case – remove all carriage returns (`r)
9 K& I7 K! N1 l. H# u3 R6 J StringReplace, full_path, full_path, `r, , all
9 c4 C3 ~1 l3 J( N IfInString full_path, \' A7 s% X4 Q, T9 Z
{
! G+ U5 g; b7 [: j Run, cmd /K cd /D “%full_path%”
* ^. G4 p) n; ^+ E; _9 I) v G }& P1 Z4 \( A* |" M1 C
else# h' O0 |4 Y8 z" O
{7 R; F1 J L3 S# y7 Z" q2 X
Run, cmd /K cd /D “C:\ ”0 j9 B. j/ r+ B( H# ~6 p- {
}
- w+ u4 k" Y6 Z5 z6 e }
! b) _; p! w4 e! T8 v 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
4 f$ ]: ^8 W5 X4 \+ x1 r$ W 这段小代码肯能有两个你需要修改的地方
^' G. e6 J/ m# g 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键9 w+ I7 \, t" \
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “, f' E) x5 M" y/ v
|