此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
+ A. b! ~- ^7 `8 h 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
! H2 R/ R, Z) q7 } 方式一:, M3 C8 \2 O+ B
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
; \. n) Z5 \7 N" \' u+ M5 q" { 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和7 h Q3 T- t- w' ]4 Y6 G0 t
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。8 h# J* R- Q2 K8 C( H; r
方式二:
, g5 X$ Y3 {* g4 v7 V3 x 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:8 K4 R l7 Q' N" t- n1 V+ w* T
SetTitleMatchMode RegEx/ `0 g, y( ~1 s2 h4 M, y
return
7 L) j- }9 [$ y; e6 d ; Stuff to do when Windows Explorer is open! v: |6 X; h8 ^; [( A, W; g
;
$ o8 A+ b- y: v* a: a #IfWinActive ahk_class ExploreWClass|CabinetWClass
, O/ `0 ?$ W6 c$ o' B' `/ n ; open ‘cmd’ in the current directory$ q. n2 [% {4 A* Y5 Z4 ~. [ a( \$ ]
;! z) T1 X2 t3 z+ ^, L
#c::
; ^2 ^1 p2 q- W/ ?; q @ OpenCmdInCurrent()
+ u) X# z* P: ^$ w- { return
4 j! [# V+ r5 w0 L5 P" @' k5 ^1 | #IfWinActive
4 l7 d- w9 P8 \" o ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
( c" [" |$ J) J6 ^" t: @6 W ; Note: expecting to be run when the active window is Explorer.$ r6 w& x: b* [% o/ O8 \- v
;: n# o3 Q; X/ @4 S2 q& K
OpenCmdInCurrent(). K8 p2 q1 h5 ^
{5 ]! \ c. F' m( N. P+ F, Y
; This is required to get the full path of the file from the address bar
, _ y! P2 b1 r# V* i WinGetText, full_path, A
: p7 Q; M8 w! ~% B ; Split on newline (`n)
) @7 g% L% |4 d* N StringSplit, word_array, full_path, `n1 T F* |* N* F
; Take the first element from the array9 B& W6 d4 Y4 t& i9 ~* E
full_path = %word_array1%; d! N1 q% ?+ p+ a; h8 U
; strip to bare address8 |5 x8 q* m7 K3 l- H, Q9 \
full_path := RegExReplace(full_path, “地址: “, “”)
. p+ W, r; [2 G" X6 | ; Just in case – remove all carriage returns (`r)7 k' \3 ]* O+ ]! B7 e7 p/ H
StringReplace, full_path, full_path, `r, , all
8 u2 D, f% E+ Z IfInString full_path, \
0 W1 B) j; E6 K* F {
5 l$ d# E* ]& v z Run, cmd /K cd /D “%full_path%”
0 J% ]3 r( v9 v$ x }
1 A% E- s- Y0 s6 Z4 B% v% Z6 v& b0 G else
8 T: x; N# @" z0 T* w$ _ {
# L7 w5 L& \7 z Run, cmd /K cd /D “C:\ ”
# N) n# P/ b k }: J* e) h% S( s! ^
}( \1 ?+ Z; c8 ^% `( X
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
. U& P5 F' D( C& n4 _& f4 L1 j 这段小代码肯能有两个你需要修改的地方
6 g( q' X+ s: n& i5 `3 _: W4 g# h; | 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
S t2 J2 z1 O. f+ x& c* v( j 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
) \& x( {2 t2 Q4 K, `& \ |