此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。( p: p, ^( b$ M/ Y \ D; f
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。3 \1 L* x$ g' ?7 i* R
方式一:
/ |# x+ D9 p6 q f6 W q; } 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,+ C" L5 { {1 d5 P9 L' q
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和* `' W, l# ?5 A" d$ N. M5 `7 c
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
9 P* A& u/ O3 V9 Z7 H5 C 方式二:3 \: j% z* b o$ `$ e8 n
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
6 p7 ]' @& Z( d4 V6 f SetTitleMatchMode RegEx) {5 p# t8 B- Y5 E- O; h7 H
return4 z F: q4 y. x6 D, I$ ^
; Stuff to do when Windows Explorer is open. l( w( x9 u5 b; w
;) l) `; _; A6 K9 r( d
#IfWinActive ahk_class ExploreWClass|CabinetWClass
' I) ^0 g$ D5 p5 [4 t3 r ; open ‘cmd’ in the current directory% h9 r/ e) B7 V' z# e& X5 `
;
$ u# h9 s& l g; T; ]) ]( Z( M #c::
+ J; a& B Q, g OpenCmdInCurrent()9 f5 `8 [, S' m. a' v
return) K" ?5 L* F: I9 w
#IfWinActive
' g2 b# z: w! \5 j ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.# x4 d x9 H2 M) u# @ Z
; Note: expecting to be run when the active window is Explorer.; l" t! i- P# E6 I, \& f F
;
8 T* B9 d1 W$ p/ [: M( b OpenCmdInCurrent()' B" i$ W8 n7 R* A0 S5 X6 z
{" c9 v# F, \3 m6 w
; This is required to get the full path of the file from the address bar
- t4 B+ H+ _& Z6 z, {; e: }1 c: D WinGetText, full_path, A
3 x/ j" M6 D* G3 e* t. ?9 O& k ; Split on newline (`n)
9 e. y) ]1 K6 d/ C+ w StringSplit, word_array, full_path, `n
F7 H8 C2 M6 t+ z ; Take the first element from the array
( Z5 t/ o* ^1 H) X8 l full_path = %word_array1%" F2 N3 ]' T9 s" a2 M- C! s
; strip to bare address
; ?+ W9 \, `4 ~: y# C6 n full_path := RegExReplace(full_path, “地址: “, “”)
: U. l [3 k: P# Y3 e b6 b1 L ; Just in case – remove all carriage returns (`r)1 Q5 o1 I5 h4 w
StringReplace, full_path, full_path, `r, , all
0 D; Z1 A5 q* ?8 p/ j- N/ C4 q IfInString full_path, \
( T8 L' C6 H- C8 f1 V( { {) _8 _: z6 n9 z; S0 w& y3 g
Run, cmd /K cd /D “%full_path%”
) O) d$ M4 `( n }0 z7 L# d+ A3 ^, @, `# g: a
else( ?0 h) s) |4 H; ~1 o$ v) F
{
7 _5 x# v* Q, D( k6 { Run, cmd /K cd /D “C:\ ”
- H. G* R) g$ H. u* q+ ?' U. X n }
3 V+ B$ E, C1 \ T' o8 L1 T4 ] }
: G; N6 u, S* S( Y4 Y 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。% {, Q6 H/ S8 T3 d$ A
这段小代码肯能有两个你需要修改的地方
5 ?: x8 M3 ~8 J& |: N 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
4 r0 W0 u+ T! t N$ o& N 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “" b2 c: v2 m' C6 }% G$ H$ ^% v
|