此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
" g# H% o- r! t7 H2 v; V3 u 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。" x" j8 c) h. ]* ]" Z
方式一:
- z* K1 P6 _% x( J 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
' c: i# h6 U: o% c, b& P/ U- ` 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和5 k: Y* I' ]6 y* v
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
" Z/ C: J, p- R; g 方式二:
% K/ q% |& k# l1 r0 u 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
8 a) Z' N4 P( m( n6 P: P" _ SetTitleMatchMode RegEx
! J% t" W1 i+ t3 a" B return
$ M$ }4 x! u$ j ; Stuff to do when Windows Explorer is open
X6 ~# u" R% i ;
6 l9 O" f. V) a #IfWinActive ahk_class ExploreWClass|CabinetWClass
' m; i) O- g1 m8 E ; open ‘cmd’ in the current directory
5 \1 L6 R" w2 l! h8 j- j7 y" _ ;# _# w' z; ]" M$ J: g" ]
#c::
8 S$ A5 M% ]" Y. Z2 h# I7 W6 k6 L OpenCmdInCurrent()% w( ]8 L- G8 h7 I" N1 T
return
4 V: L3 H, t# \( t7 P7 y #IfWinActive, i- W. d+ O* [6 p& M- p7 g) U, A3 q
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.* {* M- V7 M- \7 J
; Note: expecting to be run when the active window is Explorer.
& A q2 o7 w" ~" z- V ;
; n2 M% b3 E/ u OpenCmdInCurrent()1 T$ |0 J9 a! \7 r
{
8 I6 y5 s. \. j) P, r m- i1 G ; This is required to get the full path of the file from the address bar8 y4 o+ R$ O4 }
WinGetText, full_path, A
: D5 Z7 `+ q( o2 |9 B ; Split on newline (`n)# m- Z3 ~, K* j; Y
StringSplit, word_array, full_path, `n
: y! x* o2 N2 J d/ v/ D ; Take the first element from the array
3 ~9 Q$ x( A# b full_path = %word_array1%
' c* g' g* ^$ z* b# Y8 `# b ; strip to bare address% g6 W. C1 I- r! d, J
full_path := RegExReplace(full_path, “地址: “, “”)
5 r& M$ c8 w2 E0 l2 M9 f ; Just in case – remove all carriage returns (`r)* ~6 @3 o; F' Z' Y
StringReplace, full_path, full_path, `r, , all3 f8 `6 _1 h: _* T
IfInString full_path, \
2 g' f* I4 s! G8 U/ l" j+ m/ l {
# A! W- G: b! Z/ D$ C& v, d Run, cmd /K cd /D “%full_path%”
/ ~( G& }8 E+ T. ]1 \! v }
. S7 \; _% L+ i0 ^ else
. n: `, X5 u- n+ d7 {3 f7 ? {9 p7 b. h- x4 h/ I0 Y
Run, cmd /K cd /D “C:\ ”
7 _, _7 H% F5 E( @' s }
: e( ~, n7 d' W* D; l# s/ y& h# i) \ }
+ t: K9 F, h% F3 b. f* j L5 u6 ]8 t 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
7 [2 x; k( b% _2 a& f* Z; L/ @ 这段小代码肯能有两个你需要修改的地方
& P8 c+ N4 p- R/ n4 r$ n* v% O 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
5 c- b: e) @5 l5 r; `; H* | 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
' J- l% x7 T8 H; ^! \) X |