此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
$ \) |" I/ |; t/ ?, r; }1 E) Q4 i 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。# e, T4 o. E. g
方式一:2 T8 v q: b* y W
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,/ T+ c! h4 r3 e
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和3 \4 K% K& H7 x0 w- [* x6 i- h
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
% z! J. @: H& [8 N 方式二:' r2 e2 ]! \ Q% c& F4 l2 S! E
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:/ L9 A% v! ?! Y+ p, w2 h+ s
SetTitleMatchMode RegEx2 ~3 }( [2 Z) |
return
" H0 s. y7 }6 Z/ a' R ; Stuff to do when Windows Explorer is open# ~, V" r2 V, V
;
7 L6 _3 s) r3 u% Q #IfWinActive ahk_class ExploreWClass|CabinetWClass
$ `# j& l( h# F5 O ; open ‘cmd’ in the current directory6 u6 Q# o& C/ W2 [
;
/ H, o8 P: O3 O7 h; @6 }! h' i1 g #c::
3 W" a6 Z; ^. r/ @; v OpenCmdInCurrent()
1 C$ B: N' d* p" v# a return
7 P& s. T- B# Y5 S( V7 ^ #IfWinActive S1 V' q, v! W8 h9 x# {
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
+ }; V9 F; g1 Y ; Note: expecting to be run when the active window is Explorer.
% y( U7 R9 P6 L7 ]. p- D ;
% Q& ?3 A. K& C- j7 g* |2 J OpenCmdInCurrent()
" |* n4 X* F$ R% \4 N7 v3 o" B4 | {3 O7 b, Z& M! f
; This is required to get the full path of the file from the address bar
* p; S' u0 v7 |( E, J WinGetText, full_path, A
9 n# F3 H+ V0 F/ L: A% T ; Split on newline (`n)
0 r, V* `# v) J! q- Z. c. J StringSplit, word_array, full_path, `n6 w4 g9 V9 t9 p8 x3 b
; Take the first element from the array
( |5 e! d8 x2 S. @5 r& \ full_path = %word_array1%% ]- s8 u) @! P w
; strip to bare address
4 M$ u a& u5 J o" x full_path := RegExReplace(full_path, “地址: “, “”)" W T+ g$ m( l8 x C. V
; Just in case – remove all carriage returns (`r)
! d' W4 e! J \% p. H StringReplace, full_path, full_path, `r, , all
3 D: i: |0 i+ a8 f7 v4 A IfInString full_path, \
6 Q0 d. s! ?" x$ n- U2 ^0 Y5 c i {) s) b' r( a! v& x3 J
Run, cmd /K cd /D “%full_path%”/ l2 r+ H, l# h, O9 S
}8 O) h8 T* `7 F( E8 ~: y# ^
else" t% S- p1 N" _
{
$ l3 T# i3 {0 q9 j9 n* ? Run, cmd /K cd /D “C:\ ”1 h8 g. c& b. q
}
$ z1 @# _4 r3 L( m( D }1 v5 y( [1 o0 G' \. |3 m8 |' Z
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
* @ ?- {1 l |% `; |) d 这段小代码肯能有两个你需要修改的地方4 {4 ? m# D. @
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
1 `! {. ? O2 i, A+ J; P 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
7 O, F. `1 I6 B9 w- V |