此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。; @& R$ g6 `1 n P& B% N
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
& K; g# [1 K; ~0 _; p6 k) t- u+ @ 方式一:
7 P0 ~8 v+ d7 N& s& P 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,0 `9 {) q' ^( k' x* N
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和# W& E3 M; o- h- _
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
" U8 }5 Z6 s6 p# m 方式二:
+ f& m0 c! p4 e9 \2 {" ] 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:$ u) M. E5 `- }% J$ U7 q
SetTitleMatchMode RegEx. e# J- B: t" z: _) P Z5 t* L- K
return
; e9 Z4 r% t+ G$ q' P' y; H, @: H* z% H ; Stuff to do when Windows Explorer is open) p3 q$ F- y% j$ W
;
I1 w, x7 o3 E" \: ?% [ #IfWinActive ahk_class ExploreWClass|CabinetWClass+ U# H- e$ t6 _1 X# G
; open ‘cmd’ in the current directory
, u* Z; m: W. ~ E2 P ;# s2 b* h0 \+ ~4 i" Q |2 v& e' v
#c::
4 F f) S8 u9 c( }9 P1 J: l! L OpenCmdInCurrent()- d% J& y# ?& @# Y7 ~
return
. E/ g4 L, O6 M# v; ?3 b& R; T. r #IfWinActive! E( f3 y; v5 J' ?% g' e+ B# I
; Opens the command shell ‘cmd’ in the directory browsed in Explorer., y2 g# P, ^8 J: ^
; Note: expecting to be run when the active window is Explorer.& s8 u% |4 e0 R- P- c$ f
;
9 O. D8 `' [$ ~ OpenCmdInCurrent()
( I: Y! z. [; c( v L0 O {
' U' M" ~1 p% ]7 \ ; This is required to get the full path of the file from the address bar; ]) V$ v3 | P; g2 T
WinGetText, full_path, A
1 t, k7 e2 n" T* Y ; Split on newline (`n)! d. X6 r( b, u2 L- B+ M
StringSplit, word_array, full_path, `n
3 |' e/ r' C5 p ; Take the first element from the array
6 x+ H9 W8 \: [- V! o, ]$ K full_path = %word_array1%
$ O! y' e& Z- \+ V ; strip to bare address
7 {- `# c) c: m2 S full_path := RegExReplace(full_path, “地址: “, “”)
! B: B, {* ]4 ]: {2 F L% G! x" \: W ; Just in case – remove all carriage returns (`r)
. T3 K8 i& o: {* N StringReplace, full_path, full_path, `r, , all
8 h/ }1 F" h6 M9 l) C IfInString full_path, \
. f$ O' V6 ]. s9 l {& \* W/ x: z/ S$ u; Q* \
Run, cmd /K cd /D “%full_path%”
. m% k3 {2 u4 v$ n- B/ Y+ p5 C }$ j/ o7 h# C- P5 Y
else0 w0 |, C$ `5 W6 X: d, [
{
% |' }+ Z1 e" k* f3 H Run, cmd /K cd /D “C:\ ”( @% V3 c3 w! X) @$ |
}# R. F" R2 f k, X5 r, U
}
" P0 F9 r& g" y. {% S) q& J 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。! V$ C& G% j5 t% x6 N( b
这段小代码肯能有两个你需要修改的地方
; W6 I5 C* S' b" L 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
# B5 |/ u+ t& ?; U! ^ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
" p6 o, \3 M0 D: q |