此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。3 f7 R6 B; E) ?! }' D
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。1 T# b0 n+ F! U0 J7 O( j; t
方式一:
/ e; X1 ~2 ~) N6 M4 E 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
/ U# J1 |0 v% z/ j% K% m 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和) T( X! h s( `$ B3 |! y
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
9 i: w# [: B1 ]0 ~% t 方式二:
4 S1 W4 p$ A I8 e* Y! o4 N 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
W7 n( n Y- e SetTitleMatchMode RegEx
5 V) F0 W% | s) d( p3 m return
z/ h, B0 [$ Z/ j ; Stuff to do when Windows Explorer is open8 g+ h1 K3 h& }7 G
;
4 b8 Z/ t, p# H #IfWinActive ahk_class ExploreWClass|CabinetWClass! S$ }! R' v! k, k2 M d0 v8 k5 q
; open ‘cmd’ in the current directory
- Q' X7 y! g% A$ n ;
2 A+ ]1 |6 m7 v8 y6 K, Z/ \7 H #c::
+ J$ b' W0 x' G3 M8 e% V OpenCmdInCurrent()
& {; {; u( C& |! p" w5 D6 p; i return9 Y/ u& C" F! i' f. I( n
#IfWinActive
4 k8 B5 v2 V: g% w ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
( f. s6 n5 R6 g- Z1 d ; Note: expecting to be run when the active window is Explorer. o8 l+ z" k0 G- V3 [. O/ s
;
3 t6 ]3 H4 M I. L" w OpenCmdInCurrent()9 R9 u- z% G" e# {
{
1 i& G. H) t. h/ V0 Z# R9 f1 F ; This is required to get the full path of the file from the address bar
1 L5 I- Q+ G7 S4 V WinGetText, full_path, A0 c3 a; n9 H* Q" n5 \2 _
; Split on newline (`n)/ Z6 e. g/ r- e2 m
StringSplit, word_array, full_path, `n
% }0 R3 `7 y V, i* v; b5 X ; Take the first element from the array' E: Q2 I5 y; Q3 ^ N3 [$ P, B
full_path = %word_array1%
& d2 {, G2 S& S8 [$ { ; strip to bare address, t' G4 c# N6 k) C. }; g
full_path := RegExReplace(full_path, “地址: “, “”)
2 s, s2 l1 Q5 k$ } ; Just in case – remove all carriage returns (`r)
& ~& L; F# D9 A) x; z' Z* d2 ` StringReplace, full_path, full_path, `r, , all
# s1 S+ v& T. l! T( C9 ] IfInString full_path, \+ y$ q3 I h+ Q2 T" J; U
{
. N3 F8 X9 ~! G+ g Run, cmd /K cd /D “%full_path%”
+ y, T( |& R3 q }
! ?' r# F1 X6 K% | else" V; H0 C% u2 W# j
{
- C0 G6 m7 }7 b6 w) m5 A2 L Run, cmd /K cd /D “C:\ ”' [" Z9 O! n9 t4 c. |' O* N. l
}6 |+ b: ^7 J$ v( X1 {- m
}
$ U3 T4 h9 [) n0 u8 _ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。. E$ H3 M5 }8 ~2 I, A% ]
这段小代码肯能有两个你需要修改的地方
7 b q; a; i: i9 u5 Z3 \ K4 a# z 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
8 }; \! X) M5 K+ h6 x5 l4 [6 x3 Y 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
# J# D" h- f3 r2 m! r" U2 S0 w |