此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。4 g/ [4 ^$ f) Q' P- r
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
; `: C m" b1 V/ h) V1 k 方式一:+ \& U1 o8 e- g% r' @5 y
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
) E8 ^2 Q. D& f* d! s 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
- b& s8 |0 K1 h0 L: |; Y* v4 [ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
3 s% e, E; G& r( a% v# M 方式二:
- F; ?) i, x3 ]3 o- X1 e 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
; G: N7 ]! @7 L6 p SetTitleMatchMode RegEx
! [+ u: P; w; e' C' ^ return
1 y" S; o) }- y+ |# d ; Stuff to do when Windows Explorer is open
3 V9 ~' T; z, s" g; T6 A, u ;
- X' |% D1 c$ ~ #IfWinActive ahk_class ExploreWClass|CabinetWClass
. i( r) U' b5 @" a ; open ‘cmd’ in the current directory
) i: L& D- V. }1 c ;. ` i3 L& x6 m$ ~: s5 N. }: l
#c::* G) Z3 k" f2 _0 o
OpenCmdInCurrent()/ I( l: l( ~0 p& K
return
! Q6 K3 c' X, u #IfWinActive- f( i* }) Y2 H+ l x4 N
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
8 Z! u7 Y6 L! d" H; F6 C1 u0 _ ; Note: expecting to be run when the active window is Explorer.9 I2 _) l' z3 n: r$ j( R
;
, y5 ~4 l4 x& U/ F7 P3 J0 \5 `; Z OpenCmdInCurrent()
' y5 o+ T9 K. R: X7 A- q2 [* x {$ C& T& q2 L7 K& \; I0 G1 d; T1 M; l. A
; This is required to get the full path of the file from the address bar
% ~9 ^7 |# ]% m% U6 x WinGetText, full_path, A/ N$ s9 D$ d2 k* b x' ?- K9 R
; Split on newline (`n)
. D+ Z* L- B, Q( ~$ ~# B StringSplit, word_array, full_path, `n
! d+ K# M3 H' F6 A ; Take the first element from the array; e3 }4 D1 w- P+ v& d2 s+ S
full_path = %word_array1%4 U1 L3 J- d+ S- p% f! C9 d6 P
; strip to bare address
3 k3 n3 f3 U* O. Q1 ^ G9 T full_path := RegExReplace(full_path, “地址: “, “”); j# F& N) h! M( Y! n: s9 @
; Just in case – remove all carriage returns (`r)
# V6 b6 \0 S! y" J' O7 e8 g StringReplace, full_path, full_path, `r, , all+ ~& j; U1 b* G
IfInString full_path, \
, r- o% Z6 W7 S, Q6 z {
/ I# k3 q/ s; }, j0 G b! g Run, cmd /K cd /D “%full_path%”& N; ~$ C: [& y& j; o3 b# o' w
}2 q) V1 {1 I- f* h$ P0 O) q5 f) w
else
; ]$ s9 r. P8 ^2 N6 @ {
' u1 a( F% a/ @# e6 H) {( e* ? Run, cmd /K cd /D “C:\ ”
! T3 Z( j& U7 E4 T$ i }
- Z8 ~, u0 ]2 ? }
% d, t6 }. y% h7 N( F- f 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
1 k" z2 J$ `3 F0 a 这段小代码肯能有两个你需要修改的地方
- ~( U8 S7 n& m 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
) {' y2 C4 G$ f- q% } 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
6 w6 N l2 g+ f! P3 a, t( k1 ^ |