此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
6 m! B- f& r6 d6 A4 f* I8 ~' t 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。8 g# |" W- z( |5 @+ B7 _
方式一:8 K- K* r% n' ^1 U. f1 v
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
& H3 [/ r. J2 K0 [, T2 U 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
, Y1 H/ ]. u% s+ V0 C) h9 ` HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
3 b( O7 L6 O- G% u) u 方式二:
4 l. ]* |5 t2 g% X 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:7 }" b( Y1 o& N* j. W% T* h
SetTitleMatchMode RegEx4 D2 T1 L2 i- E( l( K9 Z
return. Z b1 s. h7 _/ B9 G: x! \
; Stuff to do when Windows Explorer is open
# m+ ^9 |, `3 Y* V ;
7 r$ J; x8 [; l$ @ j2 b #IfWinActive ahk_class ExploreWClass|CabinetWClass
, z6 Z9 Z: u2 l# M5 p* L8 i ; open ‘cmd’ in the current directory, V M: }8 r( l1 K* R; R, |( o
;. B: ]& L; N! a# t
#c::2 |$ Z0 u& y) _3 ?% @
OpenCmdInCurrent()
' _0 R& `7 Z0 C return
" ^, w# q6 q. @, |2 f' l, N0 U #IfWinActive( C6 d! R+ I" e
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
% h- z+ P/ O; _) J# r! W; w ; Note: expecting to be run when the active window is Explorer.$ c$ F) ?8 U- H- k7 {1 r t/ ]
;4 H! ]) f, w; C3 ~# Z
OpenCmdInCurrent()* |" R' u$ k2 a# Y" A9 c8 v7 i
{
+ z1 c! W1 s+ ?' B ; This is required to get the full path of the file from the address bar; h" P% K5 ^4 [9 F9 K1 ^- a
WinGetText, full_path, A
# c1 y6 {$ g, [ ; Split on newline (`n)
9 y) J9 o: A% }" ~7 E# ]1 h3 c7 w StringSplit, word_array, full_path, `n
; V7 [, T8 b( f8 z- }6 ^9 G ; Take the first element from the array
7 q7 Q2 ^! x. }* s! M% n full_path = %word_array1%
6 _+ r. y0 n7 V0 ? ; strip to bare address
* ]2 Q2 k& T# C( W; V full_path := RegExReplace(full_path, “地址: “, “”)
% s$ ]' C) Q+ W) R: P3 G$ s ; Just in case – remove all carriage returns (`r)
; }9 A5 w- T/ W/ D9 F7 B* y StringReplace, full_path, full_path, `r, , all
/ F1 v! ?% u B' b2 \ m IfInString full_path, \3 v& ]! }: r' l* |5 n$ ^
{5 U3 A- Z/ v7 Y+ s \* {
Run, cmd /K cd /D “%full_path%”
( j5 ]2 F4 B( W" h, M6 a' V }
- B) ~$ T$ w: W+ E$ Y% m8 C else, Q T9 w8 h, q( |) q3 h
{* S# _( G" u- V& f- F
Run, cmd /K cd /D “C:\ ”
6 V2 [0 m) I8 L6 n, n% a! a }; a3 K5 l' L5 ] H. M! Q0 T3 \
}. Z+ D9 E2 X: O) N" y
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
' B# t5 X! r5 X 这段小代码肯能有两个你需要修改的地方
( {+ B4 n7 N3 u% \) q( N! O2 Z2 y 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键0 b1 n* i7 N* X! }" b
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
, Y7 v$ }# V* M |