此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
& |' f2 z% e( n4 f. [ 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
' `. Q5 a h; |" M, @0 N/ |+ T 方式一:
2 ^9 Z/ y2 \# t# Z 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
$ @* I1 \+ P5 ^0 b* i8 B 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和9 z# W: I6 ]$ z1 Y0 Z$ g( {4 J" k4 B
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。* c" ~ d+ D2 d1 Z2 N
方式二:
% b. H! s ~; P* S* J5 |3 h: \$ s2 { 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:! ~1 |& Q' Z9 a9 z) [ C
SetTitleMatchMode RegEx$ X& M0 D6 r1 q* Q6 x
return
3 {8 M7 n6 @( r+ B ; Stuff to do when Windows Explorer is open
' X1 J& G6 j* {% ^$ j0 t4 K: W ;
8 i" G2 p ^; Z/ |* I/ a #IfWinActive ahk_class ExploreWClass|CabinetWClass
% ]- D( L9 {* \. q' f ; open ‘cmd’ in the current directory1 c! d- e" V p7 n5 w+ |! i
;
! ^3 N' B" y+ F #c::
, `. x5 m3 K# q6 i1 ^" O$ g OpenCmdInCurrent()
) i! N3 ]% g/ g& x4 o! @ return
" {8 G' b- r; N) R #IfWinActive
& s9 | v: r0 e( L ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.8 x9 A5 m' D( v/ m' n. N5 K3 [7 d) X0 P6 y
; Note: expecting to be run when the active window is Explorer.8 Z- z0 g" i6 R8 y: I
;5 p/ K- N* L7 n1 k4 P2 m
OpenCmdInCurrent()6 V& {! j* L! k
{
7 S, d/ t1 v7 x# h. V ; This is required to get the full path of the file from the address bar
: I8 s( ~' r9 \4 K, ^; D WinGetText, full_path, A9 Y' S2 @; \+ n4 L; u6 w4 ?8 {
; Split on newline (`n)4 Z+ {" `, B4 x+ J# w7 }* E
StringSplit, word_array, full_path, `n5 d$ i0 W$ x0 G( A/ ?) M
; Take the first element from the array! J8 X( b5 \+ S2 ]" O7 Z* h5 G
full_path = %word_array1%
+ j* h- j/ `: h+ p1 M ; strip to bare address
h& \% P, f7 Z8 V full_path := RegExReplace(full_path, “地址: “, “”)# |, W0 `& p- l& M/ }4 j- V
; Just in case – remove all carriage returns (`r)
; p3 n4 @6 ^( J& @+ Q. T StringReplace, full_path, full_path, `r, , all+ l" K0 N7 t1 y7 V* _# A; q
IfInString full_path, \
" R0 U4 F0 b# X }$ E. i {
9 v/ z. Q) d; H& D Run, cmd /K cd /D “%full_path%”
, V! H: _6 @: |% V/ u( W }: I* {5 x! y+ z5 p {8 E
else K" h, B4 r' w) @8 h$ `
{: q& A6 [% e8 e- ]+ \% o
Run, cmd /K cd /D “C:\ ”4 t8 _ L' _) X* \9 n
}7 h- C( C0 q* H$ |; p' Y
}
- i) D/ [8 `: w5 O1 T6 i) e) C 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
# p! c4 d* `& @, m7 X( Z2 M6 c 这段小代码肯能有两个你需要修改的地方- g! ^; g& i \# g' U4 k
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
( r, A: R! r! N) d. ^! ^3 e% G 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “, h) O( A8 Y, ?
|