此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。& o/ O3 y# i: r
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
M+ V1 t3 d" }# H 方式一:
6 T, @' ?; O+ B F 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,: { a8 L) s; S \& O
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和! O( G) k- \8 ^' n: t
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。" B- s" Z# |* g2 J
方式二:
; X3 q( ~7 _! E1 @5 C 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
/ Z1 a1 e6 Y6 X& _9 l/ H; j SetTitleMatchMode RegEx3 \. C6 y9 u$ O$ y8 z9 n
return
, j6 L* [$ l8 Y! O ; Stuff to do when Windows Explorer is open5 U6 {- Y; U$ t( _6 C2 o( x
;3 `' s* x& _3 V2 {
#IfWinActive ahk_class ExploreWClass|CabinetWClass; w. [( k1 i4 ^; S' {' W# A
; open ‘cmd’ in the current directory1 o% b: {" J/ _* E& B
;
* b: x8 M7 n9 ` #c::/ J5 U4 a/ |* E( r. q5 f
OpenCmdInCurrent()3 y5 I8 {) o$ o G
return
" P1 k7 S: U2 ^6 b0 ?! L! ^ #IfWinActive/ R8 W7 m+ P+ }# K$ V- m
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
# G* N. i N: k+ Y6 o) Z) W ; Note: expecting to be run when the active window is Explorer.0 b% h& \" I3 i8 X1 m4 O0 d& ~
;
8 T4 `4 c" N4 e, G3 o OpenCmdInCurrent(). E Q6 j+ S! B! u. f1 e P
{
' t/ J/ g% j. N0 ^/ _4 o0 F ; This is required to get the full path of the file from the address bar
' y6 e2 r- @) F0 H6 K WinGetText, full_path, A
' T* z) e% L% i6 ]1 W, i ; Split on newline (`n)
8 D9 b( C$ |4 b StringSplit, word_array, full_path, `n
/ s$ Q5 r8 x. s" ~4 W& u ; Take the first element from the array% i9 _! x0 o# L) O. T f
full_path = %word_array1%$ K; u$ }" j2 |# z
; strip to bare address) i6 I; s: w4 t5 f, z7 W" [. j
full_path := RegExReplace(full_path, “地址: “, “”); l- x+ b; f) K$ @4 c: l/ L
; Just in case – remove all carriage returns (`r)+ t+ a J$ M% _! s7 }
StringReplace, full_path, full_path, `r, , all8 Z! i' r k" ]( u
IfInString full_path, \
8 E7 |3 i& p' c ?. q2 y {, A0 T; w& u! ?( O
Run, cmd /K cd /D “%full_path%”
% k0 y' m. t+ q2 {2 L# ^, s }, P1 V- q1 m s; Z3 n+ g* S
else
- o+ @, q, ?( d) J: B9 E/ F {! b0 O4 s) S( v. P9 G7 Z3 v
Run, cmd /K cd /D “C:\ ”( a0 x, L3 G+ }6 }1 L! v
}
5 \6 V7 _) U/ r. D1 X }6 V |, |1 [# ^8 h% H
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。! f, Y% z6 V5 s- F9 ~' G' v" n
这段小代码肯能有两个你需要修改的地方
4 @8 R/ d9 E$ V, @7 H 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键, v# O8 }. K3 I1 A9 \3 m2 r' C3 w, h
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
3 t% j9 ^) I5 W( [6 m' f4 S( m7 ^& Z# _ |