此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。6 Z& \' }2 v" @( Z7 c7 L) b8 K
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
, |. V, B$ y# K) R4 |. U( B. S+ q* E# i/ Q 方式一:* {3 |3 z8 U9 y9 ^& k. r
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
( B+ S$ c6 A, a+ Z0 B3 h 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
7 D3 ?* g* t4 C' D' n/ I3 ?0 I& K HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
) E" `( I/ K5 B$ {9 O& X 方式二:) A3 Q* L8 @; M9 {! @" R
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
2 P" R. T9 i# h2 r" V: J SetTitleMatchMode RegEx
3 E+ C- l! u6 w. q0 a0 I, p return
9 @8 G( J' o$ q* @1 p ; Stuff to do when Windows Explorer is open' k% f8 i" _9 }9 I( z
;6 Q4 @# M c; U, x& {
#IfWinActive ahk_class ExploreWClass|CabinetWClass5 Q: F0 ]8 R7 p$ N9 P) M/ |2 v
; open ‘cmd’ in the current directory
+ A6 U- g' Q& W ;
, T8 V8 `# B9 x9 a, {1 c- E #c::3 D* z8 |$ c9 B6 T4 C
OpenCmdInCurrent()6 t* ]1 l) s+ z; a$ @9 W8 j
return
+ c( H' T% {; n; [% ^( b #IfWinActive' ?8 \9 ~* g E: E1 J ]
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.8 J$ q9 N4 v% z8 b3 [: f: V0 b
; Note: expecting to be run when the active window is Explorer.; b) P! j( G# n+ _, i+ W$ Q: e- y
;
+ n3 {( M9 b. \% j OpenCmdInCurrent()6 }. T9 ~( N7 a$ a, @, J; D
{
# A" u+ z, N5 z5 O" t; s, M F ; This is required to get the full path of the file from the address bar
3 Y5 a" U$ r3 l9 R( e# c$ w4 y WinGetText, full_path, A- _ m o+ v5 R7 u2 Z$ h' |
; Split on newline (`n)* K: D8 v: i3 J' J% [& _/ j7 C$ G
StringSplit, word_array, full_path, `n
9 u! K8 e# S B7 S ; Take the first element from the array7 ?7 A( E: y0 {8 J8 u8 [
full_path = %word_array1%
7 z l0 t5 W7 ^, B9 m ; strip to bare address
! }% H$ `) {" R/ S full_path := RegExReplace(full_path, “地址: “, “”)
. Q5 [: i1 d# n. @2 F/ @ ; Just in case – remove all carriage returns (`r) J4 T! L* }$ S+ ]
StringReplace, full_path, full_path, `r, , all
- f, i4 c8 K! I IfInString full_path, \6 {% d# S9 ?5 S( |1 ^+ J
{
- {. Y6 h1 s2 g Run, cmd /K cd /D “%full_path%”+ @' ^! S# v+ l1 A" n
}: @) V- P% R' H* f
else7 J9 y( t9 d8 x4 [
{: v- V6 K/ ~) o/ h- u8 Z; M+ E
Run, cmd /K cd /D “C:\ ”8 m' V s: L- w. z* R9 W! y* l" w% c! E
}
# f, W! ~ y5 |+ L$ v, M# t: @" c }) K- U2 `7 e0 ]5 S8 a* s6 u" R
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。8 ~ C5 K- G( K3 C( v8 {
这段小代码肯能有两个你需要修改的地方1 S( N* [/ c. @" [, c' r5 t
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
3 D$ v! S2 {9 P8 t 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
5 T7 U5 ^3 r7 q! a/ L: m |