此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
* e7 w1 k/ B3 I6 e 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。) f2 b% }7 j5 f' @
方式一:. T9 E- C7 s, L( d+ i$ w- \
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,7 Q' l6 M/ n, R6 M" q
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和; Q- ]9 y, `$ F3 J
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
& _) u7 O, }6 A- s3 j6 U* i 方式二:, v7 y( k) g$ l( U0 P- o
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
" n' L- E4 v9 a1 ~& O SetTitleMatchMode RegEx2 X# Q; ~9 x3 u) ~, v6 v$ H
return
0 P* A* P- M2 [, R ; Stuff to do when Windows Explorer is open
- `* I8 v. @; i0 ?2 ~ ;: D6 l, {7 {, ~& m6 a$ w) m. W) r- o
#IfWinActive ahk_class ExploreWClass|CabinetWClass
7 e! \. s, n, F; |5 B ; open ‘cmd’ in the current directory
2 V2 Q& f( `: b# { ;( U) W5 U" A7 _2 i9 ? U+ e+ l
#c::
! o% P; g4 u; ~/ N3 | OpenCmdInCurrent()% y. N& n) D2 Q* G
return4 ^& K' A& Y5 D% j# ]* k6 b8 D# z! X
#IfWinActive2 @7 s2 [# \- B; Q* H
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
+ w8 R9 N3 M, A- S8 J5 I# ~ ; Note: expecting to be run when the active window is Explorer.. N0 f5 r2 }5 E4 j
;6 n# R" {" c( p5 ?/ b
OpenCmdInCurrent()/ }+ D3 _' I3 y
{
# f/ h% a, x2 U ; This is required to get the full path of the file from the address bar7 Q$ X& g2 e% O/ L
WinGetText, full_path, A
u! D* m- F9 w# Z- i0 d: w# m ; Split on newline (`n)
& A: u/ T& n/ t* ^' D' ^ StringSplit, word_array, full_path, `n# X( H) s( s& | V
; Take the first element from the array
: ~0 [, x* q% N) Q5 F3 n1 \ full_path = %word_array1%
. A4 o3 }# O8 Y ; strip to bare address
8 r: M4 `3 R1 E full_path := RegExReplace(full_path, “地址: “, “”)1 M U9 n& L# w
; Just in case – remove all carriage returns (`r)9 X1 }$ F8 j2 e, D
StringReplace, full_path, full_path, `r, , all) l9 n" M% C% Y: }
IfInString full_path, \: M3 `! p9 s3 ^) `0 M
{
, u# C$ w3 E( P1 y* `) a Run, cmd /K cd /D “%full_path%”
' ~0 Q- w: x( y& O }% a3 q, x( D2 L
else3 N; G/ t2 \0 u, _3 s9 O
{
9 k4 |" n7 ^) ^: G% F# F! e Run, cmd /K cd /D “C:\ ”) U$ s! G4 `* n% _5 U& k) b# l7 w
}6 L1 l; ~$ @+ `
}) O( }( [# F5 X' B1 j" u
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
- p3 A0 I( R2 ]% D 这段小代码肯能有两个你需要修改的地方) O; R. h& g) {: y
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
4 R9 p; g; I- z( h6 X; G 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “3 @# I, q9 d" ?
|