此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
& s. h$ g' S4 ^/ T1 B 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。. w* D5 m. i9 o! o
方式一:
0 d+ |! h3 z( m( F0 g/ l" b1 d3 g1 F 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,: `/ _" x) {; w* [$ V ?
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和+ P& t% @9 I4 l. e+ C
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
+ i& D/ f# e: h: X 方式二:% B, [3 |* S9 |
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:% K" K( C& M; D! y; P
SetTitleMatchMode RegEx
' v2 w* i5 Q0 M! m return: [+ X( [) }0 g' g. a
; Stuff to do when Windows Explorer is open& }4 m& b& H7 z N6 o, i7 D
;
% f0 A5 t1 i+ U #IfWinActive ahk_class ExploreWClass|CabinetWClass
7 ~" e! \& s5 x ; open ‘cmd’ in the current directory5 z( s; D. t" `& R9 z
;
1 E; o9 v g; E6 E- h6 v/ { #c::1 f+ D; E M5 Y$ c; ?
OpenCmdInCurrent()
# |3 C9 S$ w9 m- l1 x return
9 X4 M5 \0 @! |) P; ]6 @. g# a6 `* f #IfWinActive
. \; M# g. e5 M9 n- ] ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
( I' u- P; n4 V( k, L% y2 Z5 d( c! _ ; Note: expecting to be run when the active window is Explorer.
( G4 ?* O$ c$ j. z) `6 ] ;6 K3 L- ^$ f; R+ T3 }1 w: X
OpenCmdInCurrent()
" I$ P/ F% B. C8 v s I {- |: X' K3 `! f2 T# n5 B P
; This is required to get the full path of the file from the address bar
E$ c$ b# P2 N; f( d4 u WinGetText, full_path, A: O$ y. F" E* i" x, A: i0 C% R
; Split on newline (`n)
$ T/ ]! f; ]% p% F StringSplit, word_array, full_path, `n
& L; D+ M& |0 R% d3 I! }; u1 y ; Take the first element from the array0 N, V' x7 }" Q. c& F
full_path = %word_array1%2 M, C% t' {3 H7 k+ x, u
; strip to bare address' r" c! D2 M) u4 z) c
full_path := RegExReplace(full_path, “地址: “, “”)
$ Z1 o3 I6 u4 B5 m ; Just in case – remove all carriage returns (`r)9 d; v1 f! V, {) ~! X
StringReplace, full_path, full_path, `r, , all
. w* v5 m _* B0 I3 p: S IfInString full_path, \
/ g' j+ W1 V4 j2 _( q" t2 ]; m {0 B5 l( Z. J4 k" s; j( n S# s
Run, cmd /K cd /D “%full_path%”# ^% T+ ^! k4 C
}
/ u1 L$ x3 P }6 _ else2 t4 @# o, C' a. U
{8 _ g# l* k' l7 a5 ^7 \1 v( A
Run, cmd /K cd /D “C:\ ”
- g$ J" |$ {2 m }
' z6 e9 g2 z+ b }) N8 B- Y# r9 d w& J9 m
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。- r5 Z% k$ U/ ^6 B1 s
这段小代码肯能有两个你需要修改的地方! j6 g& Q$ I$ F3 g) l$ Y2 w
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键5 S9 l/ U- P y/ G( [' s2 o
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
. u. S5 {! z- D8 @. P7 O0 D# _9 c |