此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。1 s4 N) R: J" E& O" t: r
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。: d- N- l2 g' |1 A4 P
方式一:( g$ [: ^+ J8 s6 h* X6 X
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,2 g5 z! x4 P- D
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
3 ?; \$ v8 a, Q3 R$ T HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
3 C# {% T6 y) B' t 方式二:
8 r7 Q* C# C5 I* M! i 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:$ t" @6 \, G* S# t% X9 S p
SetTitleMatchMode RegEx9 H+ b, @, I' N) G! Y
return
8 Y' U. C( Z8 H5 B: e5 V7 |; e2 r [ ; Stuff to do when Windows Explorer is open
4 ?) H3 A9 S2 c5 s ;
6 U7 h6 k( l. t1 P: g #IfWinActive ahk_class ExploreWClass|CabinetWClass
# h% ?" @# w, h: }( k ; open ‘cmd’ in the current directory1 N+ M6 K, i1 i3 d8 @' u' J
;
* ]; f1 S( j- I; w" U0 g) { `. |; | #c::# P4 z- }; k( Q/ [
OpenCmdInCurrent()
/ X! x4 D2 K9 q1 A. i return2 m( C; A3 ` N
#IfWinActive, a1 @5 B% q" @) W) v
; Opens the command shell ‘cmd’ in the directory browsed in Explorer. ^9 b& R& c$ E6 e! C
; Note: expecting to be run when the active window is Explorer.
" u& o! p3 i6 I5 ` ;3 d6 i5 k- l- {' A; U! Y
OpenCmdInCurrent()/ c' o4 Q/ l4 c$ A9 o) Y) m
{0 _% d/ z& F4 ~1 [- E0 }
; This is required to get the full path of the file from the address bar
) k4 ]* o! r n& D% C) L, ~! E WinGetText, full_path, A
; \2 M' ]' v# E5 O7 w ; Split on newline (`n)% ~7 }! R8 J) U6 O! G) b
StringSplit, word_array, full_path, `n
% `* J9 t0 a* o+ I ; Take the first element from the array, T$ e7 w+ \, g& D H5 H
full_path = %word_array1%8 `& t( g6 t, t8 r! L( Q
; strip to bare address- b' m# H: W+ R( z/ i6 O4 @
full_path := RegExReplace(full_path, “地址: “, “”)
7 j, y! A9 o. p; g3 s9 P ; Just in case – remove all carriage returns (`r)) ]% j" r ]3 }. T% V9 m0 j& |# P$ @
StringReplace, full_path, full_path, `r, , all
* ?' \& f/ y/ |+ @ IfInString full_path, \, b7 I o3 c' ?4 t. ^
{7 D3 V7 H3 {5 S' F* @
Run, cmd /K cd /D “%full_path%”
! R2 h3 }& k# E8 B6 Z6 V) i }, t x( a8 o" S
else
( x- z V0 S& l& U: l( G! n- v {: N6 H8 ~/ X( x# }+ b1 n' e
Run, cmd /K cd /D “C:\ ”
2 G' \/ |! j% [ }
9 S% z! M( a( d t( A }
* [4 R8 N9 a3 @ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
K9 S7 X1 r2 C8 f 这段小代码肯能有两个你需要修改的地方
5 S1 l: W& o9 o* y) o3 W 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
! l- P; E5 Y" \8 O! S/ O 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “1 t6 a G- h' ~
|