此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
2 _: I' S4 i, i( e 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。! _% M4 |. _3 y! @3 L3 z% e
方式一:
+ a# w5 E6 k. h 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,& p+ t- B& w$ ?3 D5 u
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
) w1 ~) M. a* p6 | HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。0 M5 M2 b$ b9 ^. C0 ]
方式二:
3 ~" S& p4 R$ M8 i# z. G! _ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
. a' b- |, {. N O" b0 W; p SetTitleMatchMode RegEx
% g+ e5 d0 [5 W$ O: h' ]# b return
1 l5 X5 b% a" X) k: v* Z ; Stuff to do when Windows Explorer is open1 H) [6 N6 \0 P
;1 O9 }8 f# L: L, T: N% @
#IfWinActive ahk_class ExploreWClass|CabinetWClass
: U: o& F- F" h: s ; open ‘cmd’ in the current directory
% c2 H+ D# B+ L4 m ;5 |5 P8 i3 _3 B
#c::$ w/ [6 j4 l+ U1 m/ Q
OpenCmdInCurrent()
& x \5 b3 q! E/ }5 j return
- l& F9 d7 F" i3 r" T #IfWinActive
4 E9 U1 m2 h' ?, N8 S" X0 f ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.) {4 L+ _' b3 ], y7 D
; Note: expecting to be run when the active window is Explorer.
' r! ^, {. I* U/ m( c ~* O ;
9 }8 P7 C/ S% F! b OpenCmdInCurrent()# E# @" o3 l1 g- U' U- z, ^
{
( o8 ]; b! \5 m- K ; This is required to get the full path of the file from the address bar4 E g7 t% i$ @& @7 ^( W
WinGetText, full_path, A
. }: h6 `7 t+ V" y9 p8 C- t+ { ; Split on newline (`n); Y6 t- _/ C/ o( b- M
StringSplit, word_array, full_path, `n
4 ~# l% d6 s" O& `3 k ; Take the first element from the array- a$ R% Y( D- N: @% m4 l9 v4 \
full_path = %word_array1%
: \: @( p0 T7 ^! K9 k ; strip to bare address: P, c/ o+ g! D- v5 T# O* \% ]
full_path := RegExReplace(full_path, “地址: “, “”)
: c( z) J7 W4 E& M' A5 Z ; Just in case – remove all carriage returns (`r)2 I' Q( L) D9 A1 P% E) l% J/ P6 \
StringReplace, full_path, full_path, `r, , all' z8 |/ G" S4 R& [
IfInString full_path, \3 K& H! k) `8 M3 s2 _
{
- Q S0 V0 S; n- J8 T Run, cmd /K cd /D “%full_path%”
" I; M4 o. T* t7 G }
- [9 E; o% c4 l' |! |4 y else( Z8 |. @2 d1 h- \, h* H
{
5 K' K. h5 b$ v. u) Q$ K Run, cmd /K cd /D “C:\ ”1 R U6 ?8 U. S# o0 n) j
}
5 B" M, ~! u) q/ @* {* m- n# n }
* m, u5 v7 k$ D( o 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。9 g3 ^' h8 B$ v7 N
这段小代码肯能有两个你需要修改的地方& h+ w, i1 U- u1 B \
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键) p _9 c. d W% e1 |, O6 I! T
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
8 ?7 o' s) a5 U8 w |