此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。( |* L2 c- B; M
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。( b. W& F6 h6 a( `8 w6 U6 V
方式一:
' i' k2 B( [: h 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
; C/ f. V. f" `( ^$ z 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和+ e/ w/ _! w" \5 L0 Q# K
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。( L! k7 s5 k" X+ M+ X
方式二:7 f& ], A4 B9 I( a: X* R5 J
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
7 j# c6 x4 p5 N& V SetTitleMatchMode RegEx/ l! o; ?: a( V0 m2 S
return6 R0 m" Q2 s5 a& \/ @4 w3 n
; Stuff to do when Windows Explorer is open
. P" T8 n0 {: A$ ~4 y# }' ~ ;! @$ }6 n! C0 l/ y [5 Z
#IfWinActive ahk_class ExploreWClass|CabinetWClass. ?' }) l& j2 U4 Q" e" g
; open ‘cmd’ in the current directory
, W _+ Q: h, d- c3 A: J. l ;# W1 ]- y( R: n0 O; x6 g1 B
#c::- J- r2 s2 N' T* M
OpenCmdInCurrent()
% i; P+ o' n5 ]6 |# V7 ]$ F7 L return6 M/ C0 W. ]% G! O
#IfWinActive
) q0 ^7 P u. D2 x/ M ; Opens the command shell ‘cmd’ in the directory browsed in Explorer., e; p1 |" H: U8 f. a4 W* C
; Note: expecting to be run when the active window is Explorer.
; e; o: s; y- a$ h4 A3 d, Z8 K# j* u ;: N( o1 W6 \! F# P. q* ^) h
OpenCmdInCurrent()9 \" p) j- U, A2 ^1 D" }
{5 Z6 e6 R5 c' V9 S/ [9 E6 U9 E
; This is required to get the full path of the file from the address bar
2 \+ b' }( T6 H h1 ~ WinGetText, full_path, A% r6 s( |2 \7 l# v" }2 h8 |
; Split on newline (`n)
4 z4 w4 U) x$ \. `2 K StringSplit, word_array, full_path, `n7 F% L4 H- {' a( Q2 t3 w
; Take the first element from the array
7 B& K7 v( t/ y" M full_path = %word_array1%
8 O6 p1 x0 j' s6 S& q8 \ ; strip to bare address
" @9 ?! w) N( `5 @9 |- S full_path := RegExReplace(full_path, “地址: “, “”); t& T4 Z! a7 y$ Y9 _
; Just in case – remove all carriage returns (`r)* a" [2 r* [5 x) |5 C% e, i5 M: g( @
StringReplace, full_path, full_path, `r, , all! z/ e0 T, o+ ~' d
IfInString full_path, \9 N' m2 ` ^2 z% G8 I
{
& g# |: }+ K# M: T* N$ h! i& L Run, cmd /K cd /D “%full_path%”
/ Q4 }8 Z7 I( u' u- H8 x* d f- [ }
. u% I3 x$ h" p- I5 L. a0 P else
- b4 a. J9 q* c- y {
1 u3 F) w5 ^/ \4 U' {( | Run, cmd /K cd /D “C:\ ”/ m$ k& q) }, m: ^
}
5 t! q% m' I4 ^+ J6 Q! B } \6 @. {3 g, G( E7 M) D# h1 [
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
3 y* k2 g6 B4 `) M 这段小代码肯能有两个你需要修改的地方+ a( U# L5 |9 \) [
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键! ^3 z8 n4 }8 R
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
/ ~. o, \5 S% I3 ?+ l9 s |