此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
7 A! i# v! ~+ Z) n: @8 L. D z 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。* B/ G* S; n4 r: W3 k! y' H
方式一:
. S% m& ^8 ]* v8 W. n5 o 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
" f+ R6 O! I4 B/ E8 G 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
! m- b7 U! Z# M HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。/ s" `7 ^4 c! `5 t8 A" }' }7 V
方式二:
) c' w+ t6 Z, u& _7 L! r$ C 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
/ y d9 I5 i d+ P5 C9 S SetTitleMatchMode RegEx; _) F) Q4 g+ V9 j4 U P
return
1 W) m& m+ p/ N) J' g# A4 ? ; Stuff to do when Windows Explorer is open7 U3 ~+ j7 a9 P% |; G0 `$ G" e
;* h. n# |2 [- U4 J! J4 l$ s
#IfWinActive ahk_class ExploreWClass|CabinetWClass
8 S9 S. P; Z: h ; open ‘cmd’ in the current directory
8 a. }* o0 L S! h! Q- [ ;3 J: f9 ^; j+ {! Z0 _% J4 ~
#c::
; h8 i- g3 l- |/ X/ \- P OpenCmdInCurrent()
" T3 y8 c. ^* a; S return
9 j: D9 [/ ^! g; t #IfWinActive
+ J% X/ _9 L, W& U* E8 P" t ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.3 w' Y. _! z" y7 L7 a9 C" B
; Note: expecting to be run when the active window is Explorer.
$ X( p) V; B% G2 O/ D ;- x$ \$ u8 t2 w. ?
OpenCmdInCurrent()
7 W; @$ z6 |+ r$ M. S8 j {+ X' J/ v9 Q8 Q6 i: P ~
; This is required to get the full path of the file from the address bar# w, r- I# j. \* F
WinGetText, full_path, A, e3 w. n+ W: ^% U8 w- m
; Split on newline (`n)
- u: P: y& [: B& L z8 H# c7 T StringSplit, word_array, full_path, `n
* J+ W% s3 ?' T$ s N! S& R4 N3 d ; Take the first element from the array8 K6 G# F2 _, V8 q" \# A- ~
full_path = %word_array1%# M& X6 U6 b' e' j) Y
; strip to bare address/ Q0 P- f* p" t5 {- y3 E* \& M
full_path := RegExReplace(full_path, “地址: “, “”)- }. O* q! E' x% Z
; Just in case – remove all carriage returns (`r)
6 p7 u, ` D' I StringReplace, full_path, full_path, `r, , all
$ l! f, |& k& @2 p, b IfInString full_path, \ F3 p: [0 T) u, f Y1 B% G7 H+ M
{
1 e1 G' `* Y$ J6 y Run, cmd /K cd /D “%full_path%”
& E( w3 H% g* B0 ^2 O }
5 J% L& h! Z' A% B' g else0 q; Y. `6 X7 T5 C3 \( J
{$ H& ~) ~* Z) \# N% O6 ]! c
Run, cmd /K cd /D “C:\ ”
4 _8 C' _" N) l* ^, {/ ~ } {4 C, P0 a h1 o3 N k D
}* S. U9 q A- |
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。! M$ L& \# t T; [2 T4 K
这段小代码肯能有两个你需要修改的地方
& x, X# T5 g) o5 _ 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键2 N% u# o# J8 y: _" k* {
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
# o4 M% h2 p' L |