此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
, n/ g7 F- U' D1 ]/ D 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。6 F4 `) t: ^8 q6 d
方式一:
4 J$ f5 s! X3 e D3 Q 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
- t$ }' a" D/ R1 m, ] 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和- t* C8 e7 d; U
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。# t0 ]9 L$ Y" @/ y' Y
方式二:3 y) v0 O" s; Z$ H/ Y
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
6 ~6 @5 O; ?+ P4 \ SetTitleMatchMode RegEx
& ]- o1 Z" q! E( Y& z3 N8 H return
; p4 Q. X# x9 |( b/ l3 y) { ; Stuff to do when Windows Explorer is open# N( D2 c2 X; q# p( j
;% h' V z/ n, t) \9 U1 u, H
#IfWinActive ahk_class ExploreWClass|CabinetWClass
; [; G; |& f/ m- [ ; open ‘cmd’ in the current directory+ E% X, {$ U/ U6 v% ]
;
4 b b5 V4 [ |- b! ^ #c::& A* q3 q# M% m. P( T
OpenCmdInCurrent()
. V! m- e: i: H return
|3 C5 E( D6 c1 D! v #IfWinActive
# T- Y q1 D. @# B- q ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.* `4 W$ d/ c7 S
; Note: expecting to be run when the active window is Explorer.
! m3 p) o$ L) U' }1 a4 o; m o ;
4 e7 p) |( |% j4 @" z; C6 n! b OpenCmdInCurrent()% M+ |- @. ^. L' n/ A# `" S
{
- B7 H) Y. n7 L5 ]7 J ; This is required to get the full path of the file from the address bar5 f" N. P0 [0 U/ n! E2 v. ?+ H
WinGetText, full_path, A6 Z) o6 | e ]* t* \9 a
; Split on newline (`n)0 e2 X4 V0 [ H, ]: H
StringSplit, word_array, full_path, `n
( L1 K: y* q5 h# j5 ^& C9 m3 K ; Take the first element from the array
+ ~4 ~6 n8 v8 p9 v0 f3 o full_path = %word_array1%
, e! @4 p, `/ N0 h$ C* S1 K ; strip to bare address
4 N% @0 a# @- g i. \2 d L+ r full_path := RegExReplace(full_path, “地址: “, “”)
* L! U" d! U U8 O& t ; Just in case – remove all carriage returns (`r); k* p' [6 c0 O3 y
StringReplace, full_path, full_path, `r, , all6 N4 I. s+ n( a3 \
IfInString full_path, \
* c9 r( i6 A1 a {
7 d0 r. I, ?: c" ]8 C Run, cmd /K cd /D “%full_path%”- w9 i; {! D8 w/ C! x
}
* q5 |; q) X! u, t& E else
8 Y. A0 O9 x p/ j H! n7 j {% y" F* ]4 a S6 C" l! e8 J
Run, cmd /K cd /D “C:\ ”4 p3 h8 d' j* z" y& B, [
}! H: [ K) n, Y
}
, V) Z# i! z4 p$ o6 ~- ^8 I 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。" L' b& _: S( U# l: H% j, G
这段小代码肯能有两个你需要修改的地方
# T- y: }" H2 t5 q$ X5 Y5 ~ 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键( }; l# Q+ C. Y" ?
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
3 S! L& |$ e( M/ l" I! Z0 m |