此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。1 Y7 q w! ~/ p# i& h! ?% b
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
H0 [- f# O) u! ?) I) _ 方式一:
) c7 m' ?+ W" F; W$ V3 i ]) @ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
+ |+ R% z; _7 G) [' X- K 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和! ?# N* ]' X3 }; E" p4 ^# v0 k
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
) M* E) i/ ]3 N. U8 o 方式二:
: ~- z6 L4 @ E. a 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:4 \3 T" `# Y3 }) o
SetTitleMatchMode RegEx
$ u. I7 [; U, M' V return
P/ J- a: c/ I) I% @" I2 w ; Stuff to do when Windows Explorer is open
3 v2 d3 A1 f& c# \& I+ s ;
, ^+ b% T0 J% ?1 j$ n+ U/ x/ r9 ~ #IfWinActive ahk_class ExploreWClass|CabinetWClass" m2 f) }4 k5 A( M+ J2 `) n) B/ X
; open ‘cmd’ in the current directory
" p n2 ~! {. e. }0 F) T+ A) k ;8 H! a! K; ~& [3 r( j# ~& o
#c:: N0 [5 O8 I5 _! \% k
OpenCmdInCurrent()' G% v/ r- L6 k( f9 r& i
return7 S" w7 A* @# X! [; r0 l
#IfWinActive
) _& r- n3 @2 H ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.: ], v" d# v% C2 N
; Note: expecting to be run when the active window is Explorer.
5 U" m& X; }4 c ;
v% {7 D4 [# j! U; m2 Y: s OpenCmdInCurrent()
* j E+ D& h! C T" h; w {
e$ L* g, _" h- T2 a( @ ; This is required to get the full path of the file from the address bar2 R0 t5 i1 W7 a/ {9 g9 X K
WinGetText, full_path, A
; P* G4 {% G/ e% |4 ~9 y0 `9 C ; Split on newline (`n)& q D1 I) z8 u6 `6 w/ L
StringSplit, word_array, full_path, `n, C. A; C" D2 k6 g
; Take the first element from the array
. g Z; A9 A+ r full_path = %word_array1%5 f9 X9 ]; H/ v) Z0 _# a7 y
; strip to bare address
6 u7 Q/ S2 Y2 @* s full_path := RegExReplace(full_path, “地址: “, “”)
# `4 L8 A- ]# @* @7 I( ~; q ; Just in case – remove all carriage returns (`r)
2 ~0 O: N5 I8 }: Z; R' h$ T StringReplace, full_path, full_path, `r, , all
6 Z! g) r ] Z/ {& k/ X IfInString full_path, \( O( f+ }; P+ k# y$ n# @- N
{
. p; M f6 L" N! w6 W Run, cmd /K cd /D “%full_path%”
" G9 f# y( D9 r! W* s9 ~ }
' }* p" q, M/ b2 X8 z X. [ else
' ~# |/ A' b7 b' | {
3 z& g! W. y, W1 g! n" W Run, cmd /K cd /D “C:\ ”
) B; W7 A+ G( ^4 k! O& q% y6 u }. g( N. d* p' V7 p
}) M* l% `1 m- g6 Q8 R; k6 c; x0 \
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
& Q# q5 k) K( E& W' s% P 这段小代码肯能有两个你需要修改的地方
5 i8 y* f, Q+ ~$ r6 \, R 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
) V1 a+ }; M1 N+ s- [& } 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
1 g0 X- K" U( O z. D |