此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。% P3 Z; {% r0 w$ I w* ~, V3 p2 ^
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。4 E. `: Z6 v) N6 S. w
方式一:
7 ^( D8 a3 l1 y4 E* g/ f- D6 z0 ?6 M 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
7 _- I% Z/ [3 [ N1 J 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
; a2 [2 d8 X* [- h1 N; y/ x HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
: S' F7 g. Z+ |: h 方式二:
/ @0 k" s% a; y 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
) k }. C3 Q# ]3 j0 M T SetTitleMatchMode RegEx
2 B' X# k }/ j% g' L, S return) @' R+ _" H" F% K, C
; Stuff to do when Windows Explorer is open
3 {! I. m: q8 M" p: ` ;2 S7 x* I. I) B( P4 ]7 c/ ]& S
#IfWinActive ahk_class ExploreWClass|CabinetWClass' C- B) w+ g" ?* G/ c
; open ‘cmd’ in the current directory
* R( B5 L- G! N& y ;
' B1 i5 ?) i$ u% ?2 t& _ #c::
& m* {8 X9 Q6 m" [& }5 u' x& ]4 o OpenCmdInCurrent()+ t: I, Z3 B- P% H' T: N
return8 L% b9 x5 U7 ? L
#IfWinActive+ W' s4 ? Q5 A
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
/ R" J" C7 }" R ; Note: expecting to be run when the active window is Explorer.
7 N& I3 D2 m) [! r/ g/ k- M, Z* y ;& h' B+ F4 d S" T9 n. u2 K2 Y( b
OpenCmdInCurrent()3 d; B) w% \3 P) j& e
{& U; h+ r" j2 J! y8 H# ^3 v# t
; This is required to get the full path of the file from the address bar
' C, i1 a C! @8 @$ H WinGetText, full_path, A
7 R# D' @6 L! p& N/ q ; Split on newline (`n)
, i6 |7 N4 B' k2 Q# V4 q. j StringSplit, word_array, full_path, `n! u, Z& i7 F/ `5 q8 d) s# \
; Take the first element from the array
' F: P5 u/ h4 I& k4 `% e! V. u2 L full_path = %word_array1%
* H0 ]! h3 A4 h4 s! b( a ; strip to bare address9 u* i$ ~0 |' M! K/ n3 J3 l! _
full_path := RegExReplace(full_path, “地址: “, “”)
% B# n* _' K2 o7 C5 v( [, [ ; Just in case – remove all carriage returns (`r)
) A* K; F4 B0 `% x2 W3 R4 _ StringReplace, full_path, full_path, `r, , all
2 R) V, X5 P4 k( u' [, X3 t IfInString full_path, \4 C8 j/ w; E( k* ?' x5 V' V; l
{9 a! b N' o/ T
Run, cmd /K cd /D “%full_path%”
5 U1 C- U6 ~/ ]# |9 Z }
" H1 z. @5 S+ M5 @7 [+ k! S5 u, U/ I else
( C% G0 K9 ~# A9 F {
- F+ L3 {! L+ ^, J Run, cmd /K cd /D “C:\ ”
. h% W) `' E( M) Y# o* { }
. L) u+ H8 W- g8 H }0 l& Y1 x, V: `, {3 v5 {
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。" y5 R# X, D1 P2 P
这段小代码肯能有两个你需要修改的地方
4 O3 A( z9 z9 m1 x5 `* o 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键1 K. a2 Y1 M6 z: j5 G: h
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
$ s- n4 u7 {& y5 O- {; A |