此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。7 x( w8 `( c" z. s) U" [
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。7 Z Q" _, x% L9 x
方式一:
8 a3 f# D+ `$ j9 t9 m 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,8 B) g+ _8 L$ U; J3 V
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和1 m4 D; \% S1 a
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
+ c& [7 e3 u. ]% n0 M( M; ^8 w- ] 方式二:& |7 f6 X7 B6 j3 l0 l" \- E
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
k; T) X0 K; A SetTitleMatchMode RegEx
' v5 F# S( @5 ?2 m) [) I- s5 o: g' z return
) E- z: o+ O- `" s% N ; Stuff to do when Windows Explorer is open
& V( U( I* H, l! |0 I ;
3 D+ `5 i( v& {3 ^+ G$ W #IfWinActive ahk_class ExploreWClass|CabinetWClass
; N( X6 Y) r+ v% B4 |: ` ; open ‘cmd’ in the current directory
2 ~9 }9 S5 a; Y ;
" Y; g& W- W& M! } #c::7 n8 G8 h' C$ A7 S4 _$ A; x. n4 T
OpenCmdInCurrent()
1 M: r+ [$ k- P- L return
' m5 V7 y) S8 a3 t8 {2 X$ }5 d8 e; x B #IfWinActive
3 U6 j' A' D! [; { ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.. N7 h4 K ~& k$ Z5 n3 |
; Note: expecting to be run when the active window is Explorer.
, ?& t: }; h8 A w ;
: G4 T/ i8 ?! M* `- | OpenCmdInCurrent()
2 W3 G& c- Y0 ~$ y {
8 l& Y: Z! V9 x( A3 J4 K6 C# Z& k ; This is required to get the full path of the file from the address bar6 b9 H- y2 Y* r6 g4 G; I$ e
WinGetText, full_path, A
4 ^5 a, H: m. z& W( Q0 ` ; Split on newline (`n)
& ^. ^. o: }' `3 Y; P/ R& v StringSplit, word_array, full_path, `n9 X+ b; v/ K( t' b
; Take the first element from the array
; @ u" J2 b5 C# [! T+ R- X. q8 g full_path = %word_array1%- |5 u3 X$ y& G* J
; strip to bare address4 u/ C: ~) |) `, k& I, k
full_path := RegExReplace(full_path, “地址: “, “”)2 e9 g- b0 S7 l
; Just in case – remove all carriage returns (`r)
! g6 B' k5 h3 h* O StringReplace, full_path, full_path, `r, , all6 _$ i1 n# a! p I5 ~
IfInString full_path, \
& k/ C; O4 N$ Z; ?1 F9 d* S {
; R$ D! y. T- }9 C# f Run, cmd /K cd /D “%full_path%”
! D8 C. L( S* W' N' |; B }
! s$ l' E& g: l. f8 W/ T4 \ else) k2 G8 S: o- {' O
{
) }7 u* R( F' x3 z1 l Run, cmd /K cd /D “C:\ ”( U6 [" r" c' O3 b' `! s
}
M$ X! ~/ l+ z! U }
# P$ R% j# N. o3 X" k, z 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。! S+ I$ D' D2 L1 l
这段小代码肯能有两个你需要修改的地方
9 A( [, H, U$ ~4 N" s 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
# Y1 P0 g/ F$ n6 D4 L6 z8 E5 | 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “& C( h+ i3 d2 j& m/ d$ D# R
|