此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。 R; q7 N+ C# E8 W0 m
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。* t$ \, s- E& N: U+ I) I7 }. S% k
方式一:. X- ]7 S$ A2 o7 w
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,4 T+ H/ ^8 l1 B* J- z
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和" g: g. y4 R1 X+ h [
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
! z3 s# l4 H* E9 |9 S 方式二:
0 u; ^0 N }5 x8 e9 V 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:% Y. i! A, j# s* ?; ?; O# k
SetTitleMatchMode RegEx
8 |' Y7 c% T6 G! z return( g4 G3 L& N0 z% N: B
; Stuff to do when Windows Explorer is open' X2 t; \/ {$ u! l1 i( m
;
! q& P2 D- e2 Z5 m #IfWinActive ahk_class ExploreWClass|CabinetWClass
( ~' {5 n7 i" n5 b ; open ‘cmd’ in the current directory0 ~: X9 D# s' F2 e
;
/ ^- Z0 |, x, } #c::7 S) q) p1 i% ~9 S* F, g* s
OpenCmdInCurrent(); ]5 z3 J" @ c. x2 j
return
; v8 V- |7 k+ U% z0 ?, \3 o #IfWinActive/ {3 T) z! r/ `5 s
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
' B* _$ v$ N8 K. B: x2 _ ; Note: expecting to be run when the active window is Explorer.! v; ^9 H5 U! D3 ~5 c
;
4 n& B/ N$ u7 s OpenCmdInCurrent()
. |7 O1 f8 B* E5 o {
$ H" e1 ]' m' X. U; S ; This is required to get the full path of the file from the address bar) H) y! Z9 L( [( h& p
WinGetText, full_path, A1 L* U9 A4 |1 m5 O/ P w3 F0 w
; Split on newline (`n)
' w% p# Y$ _4 C2 M) e StringSplit, word_array, full_path, `n
6 m, o5 K: m4 F. I% H ; Take the first element from the array
( X, v3 l3 O% V7 r) |. z' a5 u0 [ full_path = %word_array1%
# B, P# X/ z: b. A ; strip to bare address
1 _' V6 X6 U# t full_path := RegExReplace(full_path, “地址: “, “”), q/ ~7 X# j; M; G
; Just in case – remove all carriage returns (`r)
; N7 I" Q9 F7 ^. E StringReplace, full_path, full_path, `r, , all
V2 g' q6 ~9 k( N5 a IfInString full_path, \- p, ]0 P3 R5 a$ y
{& s" R4 g3 o4 @8 L" |9 l8 y$ x
Run, cmd /K cd /D “%full_path%”
3 K2 B" h8 _: E" g } |/ V3 W2 c; h$ p: k o
else
1 c8 \, D3 y9 {' M# Z {0 {) {5 ^8 V; F9 R! a; a) |# C
Run, cmd /K cd /D “C:\ ”, X1 W0 `% V" a s! D# C
}9 M- m* K4 ?6 p
}: d# j$ {5 T3 d2 T. I
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。9 e+ Z8 t. n0 U: u( S( p1 Q* p
这段小代码肯能有两个你需要修改的地方1 e* G' S R) s* t- u& j+ _" V
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键4 L- V U$ |# f0 w' h
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “/ ]: R* K7 l F, m; _
|