此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
! _* |5 Z/ e, j r$ c8 Z7 @ 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
' v/ c5 |: K9 \, D3 W% T 方式一: d4 k% N' c. W* |( `* [8 J' P
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
# w' F' W0 ~) F* ^7 ]7 ?# M 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和0 ?3 [& ]% P2 O: u+ q- e
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。2 Y- k& u! [8 h t# [/ j- C" a1 o8 [' k
方式二:
" X5 p8 y: e- [" N! w* b" K9 v 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:" K; U& Z: Q# p( a0 g' s
SetTitleMatchMode RegEx- o$ L7 U( p* Z( Q
return+ J" Y- G1 H* v k! H5 }* q
; Stuff to do when Windows Explorer is open
" D; \0 F; o/ l ;
7 R9 L3 b) f6 s' d #IfWinActive ahk_class ExploreWClass|CabinetWClass% S( }( K H9 E' ]2 G9 i- w0 x
; open ‘cmd’ in the current directory
% D( e0 ~0 ?# W2 Z8 g ;5 r! V' J0 _& h* Z% O) n" t
#c::
. |: G. {, W& {; y% y OpenCmdInCurrent()4 @& Z' @; g" Z( U v7 F
return3 O: i1 z6 h0 g h4 D4 i! Q
#IfWinActive
& p1 _+ I! y) E `0 \/ K: f ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
5 E* G0 U4 q* P/ \8 r5 U ; Note: expecting to be run when the active window is Explorer.
1 B' n& b8 X4 l. @0 S$ e' h6 ] ;, v E3 }; Y8 L6 }/ s8 t
OpenCmdInCurrent()& p( C" b2 v" Q% r
{) ^: g3 o- x, \- z8 ^9 _: h
; This is required to get the full path of the file from the address bar) W6 X# q. h5 Q) F
WinGetText, full_path, A% U; \ V% w) I) J H
; Split on newline (`n)
3 q/ _$ H7 h# a" \- ] StringSplit, word_array, full_path, `n I; W3 C$ d9 ?/ M, U
; Take the first element from the array
, D* T% I) A- `. _; u5 V$ o9 f full_path = %word_array1%
! t6 D+ C! J5 B+ V( T ; strip to bare address, g, i( I1 z. h; F. ]
full_path := RegExReplace(full_path, “地址: “, “”)
/ M" @' d- z/ g ; Just in case – remove all carriage returns (`r)
1 Q, I8 n: j- v3 e& d% I4 f StringReplace, full_path, full_path, `r, , all
3 i; l& k, I7 |" \ Q5 R* c# ? IfInString full_path, \/ c+ L& P4 C: a0 Y+ F# Q3 E# w; O1 {
{: C$ e, e( A8 d. g4 ?
Run, cmd /K cd /D “%full_path%”* v, p$ i5 K$ W4 o
}
) Z" ~) `! h/ l; M% [1 l else. a+ c) a$ n% @7 R% C& z( O
{
1 `( ~% J0 T4 l" ] Run, cmd /K cd /D “C:\ ”
- D) d6 p) x1 e6 ^% T% u2 s, \ }2 O9 R9 p& L6 u& ~0 {
}; A2 y- ~7 Y$ u. t, d" C
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。( l% x# c! B5 @+ t- e K p7 j
这段小代码肯能有两个你需要修改的地方
, X; y* }# ?: l w# B! b 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键7 U! L# u6 M3 Y8 M" E3 [8 A
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “6 F1 N7 i2 x+ H) o
|