此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。$ g d7 U7 ^/ W4 V" i
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。7 A# U9 P- h" X
方式一:
6 O; Y- ]2 w" m% Q% |: \ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,0 H% |; S- X" ~# o* d. r8 q% H
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和' L1 t, T, C' f( J6 l' Y, q! D
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
% {% w" L) ]3 H% I( E" T* y 方式二:& ]) L: L: B( `5 R3 q, u! S
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
/ T6 t& e1 M, q; s' x- @ SetTitleMatchMode RegEx
2 D* Q" @$ b6 |; i, N0 P$ V return
/ e/ G$ G( J2 U. l ; Stuff to do when Windows Explorer is open: C9 [2 E5 R7 H0 a! w; \/ w# |
;+ v. ?* {& K3 s$ F* B) f J6 z
#IfWinActive ahk_class ExploreWClass|CabinetWClass' |4 i1 M, s: M$ j
; open ‘cmd’ in the current directory. i+ I# |( e- I0 F( ^+ L) l
;
! U: O2 k6 D5 W. x #c::
; k9 H( {, _6 j) L, b# R+ L OpenCmdInCurrent()& h: W J1 _) M' L2 S5 M
return8 c& d# `/ }* e. e% @
#IfWinActive
# z, J! G6 C6 z9 o% H# I- W" d ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.9 B, B# E( f, c
; Note: expecting to be run when the active window is Explorer.
: |: K$ ? O S: X# c# h. S ;# Q( }' o! V- f2 R, v; _# E# E9 e
OpenCmdInCurrent()$ D4 U' F; _" p2 c& A- z5 [
{
, f' t- I. Z4 \8 s8 D$ O ; This is required to get the full path of the file from the address bar
- {, Q% R+ g/ v B WinGetText, full_path, A
( O- ~4 T5 k* N. j ; Split on newline (`n)+ m0 r/ ?' Z& ]4 Q8 R# ~
StringSplit, word_array, full_path, `n: u C' n$ c. X
; Take the first element from the array1 h0 Q6 n0 N, T; C2 G* p
full_path = %word_array1%
6 Z1 H4 U4 U1 O! c8 l7 T ; strip to bare address
- i$ l' |$ e C9 D% s: { full_path := RegExReplace(full_path, “地址: “, “”)
|8 `) n9 \4 |' c ; Just in case – remove all carriage returns (`r)
+ @6 s9 ^" I3 h0 g( [ a StringReplace, full_path, full_path, `r, , all
I: D0 V7 Y2 c* ` IfInString full_path, \
5 g: }" t3 g) P {3 t' l& H0 ~: @4 B6 w
Run, cmd /K cd /D “%full_path%”# E3 @. n1 S4 ^
}6 ]3 M9 U; g! J& @/ t
else1 g- C7 o4 _ p
{
/ M+ n, O3 R2 l/ \* m) @; c Run, cmd /K cd /D “C:\ ”7 k6 o0 j" Y' J2 N6 t. s z
}3 K9 W! e4 {4 r+ W2 j
}" d, a$ w9 D9 X# l3 g
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
7 y8 ]' V4 a% r( ~ 这段小代码肯能有两个你需要修改的地方
+ L0 o _3 _$ A' ]0 C6 G2 j 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键" Z/ g/ Q, I- ]: @+ x' c
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
+ s% b7 T6 Z( G) T! _8 Z |