此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。# q h5 V* W `- _$ B, x
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
* z0 |. Z$ }( E, F8 Y* C5 x. i! z3 C 方式一:
/ z7 L$ b4 f1 g: r4 c 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,3 f6 l+ y$ t2 h4 Y6 I
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
) z7 i3 D7 \ S& ^3 |. Y2 R HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
/ V# {: b2 f3 f% J! F 方式二:' L# t# ~ j! t/ Z( Q1 c) x
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:5 |- N' ^6 X. c" w5 l6 P( q8 S& M
SetTitleMatchMode RegEx
' f7 Z# ~# r# W/ b! }: ~+ G3 r return$ a0 ~; e6 m5 Y# K- h v3 h' U
; Stuff to do when Windows Explorer is open+ G/ B$ [1 S* f7 e s- B
;& d) |; K; c1 u5 N6 G
#IfWinActive ahk_class ExploreWClass|CabinetWClass
- U* C/ t4 G) l3 ?) l2 E$ ^4 R ; open ‘cmd’ in the current directory
$ F- X( j% J+ W8 m G' l) M* w- Y4 j ;
6 {) D6 \" i6 A6 r0 L5 H, ^8 g #c::5 f" j/ N1 r8 Z. p8 {
OpenCmdInCurrent()& J' b& r& A; z, m# Z% Q" J; x
return" T( j) q3 L2 ~- y& q! j% c! u
#IfWinActive% B9 Q7 [ R$ S- v. X5 H
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.: h1 f. g |1 M
; Note: expecting to be run when the active window is Explorer.
( R2 t! n, E& ~9 ~ ;
, y+ D9 D2 R. {, C6 Q OpenCmdInCurrent()' M: L& B) e0 D4 }% d- Z- n o/ z. H
{- W8 ?9 m5 s/ v% x6 _2 y
; This is required to get the full path of the file from the address bar" F* U( r& r& @9 C5 D
WinGetText, full_path, A
# v9 |, u4 k' V9 N, W1 V" ~6 d9 v7 Z ; Split on newline (`n)
. t$ y0 i/ L4 }5 @( y StringSplit, word_array, full_path, `n
1 \0 ^/ g. c# _ ; Take the first element from the array$ q! ^7 T- b' C' ^, A
full_path = %word_array1%- D8 l& a- p; B8 `& V4 S
; strip to bare address
8 h1 Q2 H, J4 U5 D full_path := RegExReplace(full_path, “地址: “, “”)/ n8 [ o# e% G6 Y9 q
; Just in case – remove all carriage returns (`r)
7 @5 ]- U& l9 X8 `2 _1 t" n StringReplace, full_path, full_path, `r, , all
, f% T3 f; A2 J IfInString full_path, \, I. x/ O. C6 s
{3 T# E5 R9 m& B' o/ R( ?! M
Run, cmd /K cd /D “%full_path%”
' O. c, g' d: E }
# l1 X9 v/ @1 N6 x) w else+ T& j4 I0 d1 N# V7 A
{- K/ i: K, ^' m0 |7 `7 |
Run, cmd /K cd /D “C:\ ”: p! p" V( D+ Y7 G! s
}
- S( y" W7 R3 c; V6 V }5 N2 a7 R3 G. l
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。' |" P; O9 b: F; w' b- Y P
这段小代码肯能有两个你需要修改的地方
" F" x6 i3 r& M5 U' c- @% X( a: G$ k 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
" k4 g) [8 }& q3 X* q; B W 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
! @9 N" S! p+ b3 Q& G+ r |