此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
: t) A' |. ^& [9 f2 f3 r 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
* a0 Z5 F4 N/ J 方式一:
2 q3 `. a+ O- }! w( W8 D 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
2 |2 E; i K) B' {9 K! o/ F 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
; ]3 F" Q5 m4 \8 d$ D [ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。8 ]. \. {# P. T
方式二:8 w1 P* a: u3 D# a" E
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:$ {" ?+ A8 B# Q# i7 ^
SetTitleMatchMode RegEx! z) ~. {$ [. `# E8 A1 L
return
/ C* m1 x* b# H- _. k9 | ; Stuff to do when Windows Explorer is open
4 e0 e! |% S G r c+ p d ;
- H- @% @ ~" _+ _6 j #IfWinActive ahk_class ExploreWClass|CabinetWClass
0 _8 m0 e# U/ `( f ; open ‘cmd’ in the current directory: T8 H; m* D) y
;! T+ g' T, P$ E K& `
#c::
0 l9 S5 d$ z2 L. y( F OpenCmdInCurrent()4 F3 U: X# k& _# L: T6 L0 O
return% p7 E5 O- q, B! ]2 y
#IfWinActive
5 G. L4 |! s( h/ T) E/ T ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.2 u) P' `& R% h5 o& {3 Z
; Note: expecting to be run when the active window is Explorer.
2 C& [8 ]( O! Q N! e1 k ;
* {) B9 U* c9 p& Q. H# n OpenCmdInCurrent()
- B1 `. D7 r3 H+ Y {
7 t9 t* G J* g ; This is required to get the full path of the file from the address bar
9 P. G2 w( o, i9 X; J WinGetText, full_path, A
" U: m q2 m K! y- z ; Split on newline (`n)
S( S; ?5 ^$ W: C StringSplit, word_array, full_path, `n$ ~5 J: @9 K; t- A* {( X& n7 F
; Take the first element from the array
* n( I7 y8 W' p" G5 n- f full_path = %word_array1%
3 q+ h" E8 k6 y" F ; strip to bare address9 a) p# w5 a4 D! P/ c
full_path := RegExReplace(full_path, “地址: “, “”)% p7 V3 u D9 u
; Just in case – remove all carriage returns (`r)! l. D* M& `& A2 p0 j3 J
StringReplace, full_path, full_path, `r, , all
: ]8 n E7 i0 f% W IfInString full_path, \$ f4 ]& a& V+ [3 J" [
{
8 ^* ~" A+ u& y0 I0 j Run, cmd /K cd /D “%full_path%”7 _# x8 D. m) ?( _! r
}8 n, k8 r4 D& f1 p u/ J2 ]0 \
else
( ~ [6 e# Z: }, B' ~) M {
5 K0 s8 q( s( A2 J3 M- N Run, cmd /K cd /D “C:\ ”; [, p4 U d% ]
}& n( N# B7 r- G7 S
}
1 j9 i. y- J1 c; I: k+ @ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
8 ^4 K; ?/ I& p/ `9 }: V 这段小代码肯能有两个你需要修改的地方
: X3 H! G3 b9 b5 q5 E U 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
' p& T; V0 n" A. O( B* R: G 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “+ B2 j" i. s: V- I* |/ [5 Q( e
|