此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
9 M, }4 s5 [3 W g# t, q' R 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。. k. v% ]5 u! w5 s6 j) e0 |
方式一:
& [8 ]: K$ j. G3 k+ Q, I 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,7 _; a* {, K3 G# E; Y0 p+ P0 C M, l
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和7 m5 r0 R; t Z# }
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
" A z) l+ f5 P6 ] 方式二: h; v0 t" r' A, p z, \
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:% g6 P) V; m+ v& Q- M
SetTitleMatchMode RegEx
7 S8 b2 D2 `6 N0 V return
* q* I, B+ `: r, R ; Stuff to do when Windows Explorer is open
# A* x( R1 a8 f. {) T7 x, c ;: j6 R; d% x) E, N" e9 V
#IfWinActive ahk_class ExploreWClass|CabinetWClass# C) J) P$ s+ ^
; open ‘cmd’ in the current directory
7 j% F: M* Y3 p6 S# _% f/ e+ q8 Z ;" _1 \1 M) o1 V
#c::; f7 S: i- W; N$ w+ ~' V! A" A' G
OpenCmdInCurrent()
' a5 E$ A9 o1 \. O" { return
0 Z1 O# }& H1 t" }+ ^ #IfWinActive
5 ~) a! a3 B6 d6 @; _* g1 z/ ^; j6 U ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
% E# `5 j1 h( E' e: d, x6 f ; Note: expecting to be run when the active window is Explorer.* x1 T: W- u% A. s
;4 T5 z( \7 m8 W$ ^ r! [
OpenCmdInCurrent()
: ?/ D. u3 Z8 t7 O) _& R6 E P* _ {
; \" W: f6 x- d ; This is required to get the full path of the file from the address bar7 v# y" ~" g& O! f7 p3 \
WinGetText, full_path, A
; J U. c3 j g G; _6 Q ; Split on newline (`n)6 I# E. n1 s( N3 A4 g. t- S5 P1 i# x
StringSplit, word_array, full_path, `n
. M% R* ^- y" B/ K9 q ; Take the first element from the array
/ e3 A6 X4 C# o$ Y full_path = %word_array1%
: [( J7 a3 Z7 Q, c. a7 ` ; strip to bare address6 X5 P! `: H( I
full_path := RegExReplace(full_path, “地址: “, “”)
# t! m: a) {1 E4 b" K ; Just in case – remove all carriage returns (`r) P8 M- U4 N# k3 l; \: J
StringReplace, full_path, full_path, `r, , all
4 i S' T$ c7 j" e' } IfInString full_path, \" M+ G( h4 Z0 a% A" P0 C
{
0 _7 P& N2 \7 V8 ]: u( a& I, | Run, cmd /K cd /D “%full_path%”* M4 e7 T2 p( c% I% T; X h
}/ C: ?9 z6 b# z6 i5 }
else, R( U1 L# C4 Z1 c- r+ `- M
{
- c/ ~: i: f' y- k; r Run, cmd /K cd /D “C:\ ”
% Y- m r0 ~% G }
! `! J0 ]- g$ s/ O8 y }
6 |7 m) z3 t% D1 E 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。% r8 F7 ^$ w$ h6 Z( }) h B5 e
这段小代码肯能有两个你需要修改的地方
( c3 n, `) f9 y& ?! t1 ^ 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键5 `! F% R4 W; l$ @( O
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “+ s- Y: r. o! V' f
|