此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。) o5 E1 t2 j: ?! r1 W4 `7 F
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。6 [+ z0 o ~9 k* I! l6 ?
方式一:
; E' T) q0 O* l 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
" M# ^6 C' f7 \! Z1 V, g7 ] 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
5 P1 i8 A* Z% Z9 J. P2 ` HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。* V, j. \8 H, r
方式二:- a, f( G# N/ G% f* g+ k) W
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
) H7 h7 Q0 Q7 f SetTitleMatchMode RegEx& O \$ D% ~ W9 U3 M5 Z! l: q" W- E
return' l2 N3 j; k- U
; Stuff to do when Windows Explorer is open$ w( c9 d U+ R; l5 V4 z2 f# [ g T
;
4 h' x4 }5 P$ u. ?# G1 _ #IfWinActive ahk_class ExploreWClass|CabinetWClass! m* b, @! o. i% W% \( [! ^
; open ‘cmd’ in the current directory
! H0 [2 }# u# K! G0 ]! P ;
, s; H+ w# n) \$ V/ e #c::
: Q; w; H5 F* l9 H% R& \1 q OpenCmdInCurrent()
+ r" [; k. j! A return
7 X. O! \$ U/ c- L" G% i9 S #IfWinActive
% x% P e1 U2 w$ l5 f ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.( F4 u/ W9 a1 y3 R; ?
; Note: expecting to be run when the active window is Explorer." G/ g; h+ {# {" a m8 y
;
2 J# e# Z$ p+ H3 d OpenCmdInCurrent()
' z' E/ a5 C0 N' H {5 C5 U6 i& H, M# }& R8 N6 a! K
; This is required to get the full path of the file from the address bar
# ]9 N1 w8 g; A: b& k8 U' h/ n WinGetText, full_path, A
! Q4 C2 H7 V4 c3 V# B& e ; Split on newline (`n)* L6 \' @3 ~; z( P1 o! t) K& z
StringSplit, word_array, full_path, `n
- r: ?0 M h, H6 F+ d/ j1 f ; Take the first element from the array6 H* x$ P1 e& A
full_path = %word_array1%7 ~& s5 H9 b4 A7 M8 I: x' d
; strip to bare address
, k: f+ Y, ^$ n3 W C& |4 h2 P; h full_path := RegExReplace(full_path, “地址: “, “”)
$ L+ Q) h6 M( w: y x3 m ; Just in case – remove all carriage returns (`r)9 y8 N$ q# X1 k2 n1 [& P5 G
StringReplace, full_path, full_path, `r, , all
" |0 Q Q, U2 |. ~: z2 J8 ?! I IfInString full_path, \
; l+ a6 V! [) h, W1 |7 G& T; | {
1 f. B& q" I* b( a3 h7 ], R Run, cmd /K cd /D “%full_path%”' g: F6 m# b( ]
}. [5 f2 |; `5 d1 u2 e4 |, F7 h" `
else
+ c0 Q/ @6 b5 {5 R; p$ D {
! g; R. U! F3 J K1 m Run, cmd /K cd /D “C:\ ”
. [- b8 d# d* { q# ]! | }
% v1 r8 a; B8 j& Y! F5 R }
( O; R. a+ t t5 N 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。6 L! r+ [7 B/ E% c% L ^4 M4 |; w% J+ e# B3 \
这段小代码肯能有两个你需要修改的地方
8 ]$ F4 t+ z+ S) P 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
% Z+ S# O3 b3 Y0 r- M1 _ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
) U. k4 Z1 x* N$ Y# B8 i$ p |