此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。; S1 K4 w$ z" @
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。8 G Y2 c. P$ \, i
方式一:
t* e/ }( _9 |- L 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
7 c# u# o1 ^, L$ u, \7 p; _ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和, s: S& X4 J4 v2 S, S& j
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
' B: N n" G5 Y$ Y3 M 方式二:
) W6 v Z3 E/ t* [ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
7 N' e/ n$ f2 {1 b SetTitleMatchMode RegEx6 h: s! T1 ^' d% y( \6 u+ c% W
return
2 G7 R7 a* b& b$ ^8 s: m9 g ; Stuff to do when Windows Explorer is open
( `! ]# l3 c U- f ;
* `- i' q0 {, {/ K: l #IfWinActive ahk_class ExploreWClass|CabinetWClass, L o, w5 a l" M p& W+ L
; open ‘cmd’ in the current directory1 m6 T8 N% ?; |+ {. _; N
;
+ l) N7 l$ I2 H/ R$ j #c::
' k C8 k( A7 h# Z. j# v OpenCmdInCurrent()' k* X5 {+ h7 _& I" S6 u* d# ?
return
& G% d% D$ }, X: ~ #IfWinActive1 o- f5 o3 r; l% f% f7 n7 Q
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
* h. y. s& ?/ u. ?% z# P ; Note: expecting to be run when the active window is Explorer.; P; c; L) K5 H+ w2 u0 X# ~! m V9 W' r
;& n( y# t5 [0 `, n
OpenCmdInCurrent()1 R' S' J/ O# S5 e' L4 y. I
{. P; {; M8 J7 e. ?
; This is required to get the full path of the file from the address bar, G" h/ K" i+ w5 u5 M* m
WinGetText, full_path, A
- P% N" ` n. e0 W+ t4 \ ; Split on newline (`n)
8 \7 P: q* i* U StringSplit, word_array, full_path, `n
7 U& _ l' J0 x2 D7 [$ R* D2 x ; Take the first element from the array' N, h. N* y% w: ?' r
full_path = %word_array1%) `( a! {3 P/ ]! w/ n7 u
; strip to bare address
7 l$ i. _; Y- Q/ d" L full_path := RegExReplace(full_path, “地址: “, “”)9 y! @. j& `; ~! v X4 F
; Just in case – remove all carriage returns (`r)
- J! I2 ^0 | ~ f StringReplace, full_path, full_path, `r, , all7 v# r9 d% |- b6 g, I/ r; ?
IfInString full_path, \
+ ?* B- b2 R, V {
- S8 s4 B0 h% T7 _ Run, cmd /K cd /D “%full_path%”
! u% P6 \8 I2 M7 P- }/ J }
6 b" E, A' U6 j8 }) b5 W/ | else
! ]8 {: ]: w3 S {5 I% l( m1 S$ C+ R
Run, cmd /K cd /D “C:\ ”: C% w! x1 l# b p8 v3 U) p7 i. a
}
?: @4 r) V! ]7 P! L }0 \* I4 L' D; i$ c' a
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
. } {4 ^* w4 b/ m 这段小代码肯能有两个你需要修改的地方
~6 X/ N" r# z/ A0 q& M 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
6 V; T4 c5 }" X! v+ X- y; ^8 e! e 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
7 j. O1 ^" V2 j |