此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
; B' c6 d1 Z: y8 o 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。, |# v+ Q& K5 s2 ~
方式一:+ @: a/ `; x; F1 e5 ?
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,& r" O- Q: K% k$ ^8 s6 j6 Z# o% ^
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和8 C3 S; v9 T3 V3 N- C; a
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
0 g+ \' Q8 ?) S9 y6 ^% u4 S, p: D 方式二:
D9 J& w* Y5 \! t 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
) C$ h* J& u& d SetTitleMatchMode RegEx+ Z2 f! D$ X& A7 l
return
" v$ V; D7 [- {1 o ; Stuff to do when Windows Explorer is open8 p* ?+ a U2 }' M$ ?
;. ?- b" t7 F5 H; G/ u
#IfWinActive ahk_class ExploreWClass|CabinetWClass0 _. W! b; H5 [9 h7 k
; open ‘cmd’ in the current directory
0 q4 i7 [8 X/ _ ;
$ J0 W" s! e; I# b0 C! `; C #c::5 I* T- ^6 E( n/ `9 F6 a; y
OpenCmdInCurrent()( r4 t6 N" a% ]4 N. ?4 e
return
! e3 N7 U! r) o- @, ~# v #IfWinActive6 V, s! K& M0 h: X9 P% r
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.' }+ Z) q9 x3 ]+ H# G& A
; Note: expecting to be run when the active window is Explorer.+ @* b% Z* m H9 y
;
# c; x. d& n2 J' s4 e/ h: X# C OpenCmdInCurrent()$ b# E' j9 K( q2 O
{+ g4 r7 u4 ?$ r3 K' V- H1 @
; This is required to get the full path of the file from the address bar1 b Q/ Z# ~8 m9 T$ d# M' B
WinGetText, full_path, A: J L6 P7 a. q' T$ r
; Split on newline (`n)
% D" B+ E5 [/ N) Z" \/ ?8 D2 J8 d; b StringSplit, word_array, full_path, `n7 P/ Y) ~& H1 U1 `. _% ]6 |
; Take the first element from the array" u4 }. O7 U" P/ \& x' {
full_path = %word_array1%
" s* s' Y. d5 r5 `. Q9 h ; strip to bare address$ X; E$ v. w. q
full_path := RegExReplace(full_path, “地址: “, “”)
2 Z( w: q4 Y( }9 \4 C- B ; Just in case – remove all carriage returns (`r)
6 `) t7 C$ u8 S5 Z' e StringReplace, full_path, full_path, `r, , all
9 A, Q$ m, ]. i$ R/ Y6 T& I IfInString full_path, \: h6 F" n5 h6 M+ p9 I
{
7 d" g5 u& D: X7 `4 I8 Z$ Z Run, cmd /K cd /D “%full_path%”6 u4 F( H& \! {: h) ~
}
% ]# M9 M( i1 z4 E else
- D2 B( ^+ b F7 y. O' S: d {
) m/ X' l+ N! e2 E; Q$ `4 k3 Y Run, cmd /K cd /D “C:\ ”2 K4 |0 z* k8 c" d' b$ Y% @
}
2 c" a! n- V- N m$ }) b }
; n; j) S" T3 O; y 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
" \" C; a+ t! q, {5 n6 I( z 这段小代码肯能有两个你需要修改的地方
" J( C; ^. l9 F; n8 w9 w6 Z 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
( |8 s, d0 ^# H4 N5 h 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “0 K: h4 o0 ]6 H0 V6 C3 O
|