此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。' D; ~$ \$ z; p$ {* `8 a) ?: L" `
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。3 P" l. z! g, M d+ h5 e& |
方式一:
3 `* t m6 N& H* B7 J6 D% L( V 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,; e- d( w0 r' s
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和: x; T' m3 H" \; L* x$ z7 u
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
* E# H2 Z4 W- x( e/ s 方式二:
% H2 W8 i8 r' E4 V( d6 S* Y& ^. g 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
6 X8 @1 E# G$ s9 h& H. e SetTitleMatchMode RegEx( d m- r$ T5 n' V1 _
return
" H! A3 ~4 {+ [' J) q* `) i' y ; Stuff to do when Windows Explorer is open
' p- u5 I8 _9 E7 q2 G8 Y% E- ~ ;& J3 N; t/ s9 U& M4 `
#IfWinActive ahk_class ExploreWClass|CabinetWClass4 R5 P% w+ }% h
; open ‘cmd’ in the current directory$ I6 |/ J f# L$ f* B9 F/ [
;
/ m4 Z, c$ l3 Y j; @0 z% j0 m #c::
3 R! A' ], r# ?8 G- e6 i% L: a H4 ~ OpenCmdInCurrent(), Y7 V8 l- q4 f/ Q
return
* t l& ~- n; G& l- c& Y #IfWinActive' q. a' r4 k. u1 e: k- E( r
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.4 V" u* s- O" g) s! t8 k5 z
; Note: expecting to be run when the active window is Explorer.
' \9 d7 A% X* f9 C/ A# f4 m# {4 X ;
1 W/ ?7 ?, P0 w& I5 e OpenCmdInCurrent()5 d( Y H$ _, ]9 O( T
{0 S: i& s y# o% L$ p- r
; This is required to get the full path of the file from the address bar9 d+ V. E* t. x0 F. N" d
WinGetText, full_path, A
* i6 d1 Y; }# h8 m& [* k! I3 t& J ; Split on newline (`n)
% x8 ?# {1 }; n; ~ StringSplit, word_array, full_path, `n( ]2 K$ n9 A( ^, r- C' l! q2 _
; Take the first element from the array4 s6 F( B( b8 {4 B1 m
full_path = %word_array1%/ a$ r- i' e/ }- a. F1 a8 H
; strip to bare address
O6 A2 q/ L- ]3 G full_path := RegExReplace(full_path, “地址: “, “”)" r h, }3 c$ d
; Just in case – remove all carriage returns (`r)$ W- j8 S- u. }4 r; T
StringReplace, full_path, full_path, `r, , all/ } H3 A5 ~6 I0 S% u' l7 i7 b5 o
IfInString full_path, \
1 t" D& x+ [3 a3 K+ w- ] {
& E( c2 B7 ?/ Y, O0 O Run, cmd /K cd /D “%full_path%”& ~8 x* d2 H" w4 V
}6 ]* p8 q, g1 C% R6 N4 e1 w
else0 h7 ] Q A8 s) D% e; H
{
3 g7 O# Y+ V L/ }8 m Run, cmd /K cd /D “C:\ ”
$ P% w' C' ~: U4 h% A }4 u/ A( S- U5 y+ P. f" e
}
/ [1 V/ {# ~; k/ m 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
& U5 S1 x$ A/ V- m) T 这段小代码肯能有两个你需要修改的地方
$ O( L9 q% L+ ], e/ \( h 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
# U, i: A# m: o, G8 P/ ?+ D 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
& P) r, x$ B& Q, k) l8 {- }6 s3 \ |