此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。4 \* M- V3 \. M) j+ |
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。% d- c) q4 M* N, Y4 f
方式一:
, i r! Z8 ]( h" @; W 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
3 y: @* k- v9 x* U' J( E" h 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
' V; C% j' G4 R6 f) T HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
1 j2 p2 |1 k, y5 B 方式二:: Z6 m8 I$ Y2 @8 V
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:+ r0 i Q% M1 x$ d; |/ E
SetTitleMatchMode RegEx
- _1 R- [" w2 K7 O return& s1 k) w5 n8 n, O
; Stuff to do when Windows Explorer is open
- }! `1 b \! `. ` ;/ N1 y& b. \$ f4 W0 c* R# m
#IfWinActive ahk_class ExploreWClass|CabinetWClass
% K2 d; E- d! P2 H1 g% [ ; open ‘cmd’ in the current directory
. N, l" \3 ~" p( C( C9 R ;
# c) r/ ~( h9 _" m3 p #c::" x- V9 m W, ?
OpenCmdInCurrent()* D3 c: R* E# P. V2 O
return& @; `" r# [1 f3 Q3 M! F$ F7 ?
#IfWinActive: S( f4 E' v, v! U3 G; r0 B! d
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
1 w- P1 f0 h9 O4 A/ m ; Note: expecting to be run when the active window is Explorer.
: }4 d6 o4 C0 t: a ;
+ F, u! b, v% }6 H& S0 l2 V OpenCmdInCurrent()
) d" l" F: ~' N3 G0 k3 D1 Y% { {
, ?4 }, k Y b# e" f3 B ; This is required to get the full path of the file from the address bar- @* h0 m# J9 L7 ~
WinGetText, full_path, A2 ^, K4 U; E: m/ _6 [
; Split on newline (`n)( u) u) n/ B, F2 M, ?8 y1 A2 y
StringSplit, word_array, full_path, `n8 Q* j6 E" e3 P
; Take the first element from the array
( S p) i$ u; i; V: ] full_path = %word_array1%; K" d( `1 o% L4 B* d% A
; strip to bare address( b. F. U( @5 k8 x( F o+ l- r2 N
full_path := RegExReplace(full_path, “地址: “, “”)# k0 f# n- j6 G5 l# M: q9 Q F2 H5 {
; Just in case – remove all carriage returns (`r): K% G$ q. l/ d& q$ e9 Z
StringReplace, full_path, full_path, `r, , all
6 [* _! i( Y/ ` IfInString full_path, \2 D! o" ]: s: T: [, X
{
8 j8 O( C$ S' Q9 M Run, cmd /K cd /D “%full_path%”
5 b4 j- n7 a% T9 q$ l }7 N* j! H% t8 ^5 f# v* Q7 D
else
% u6 v, J1 C% `/ \/ s3 Z, m {/ Q. j! y% H* }+ _1 Y
Run, cmd /K cd /D “C:\ ”
9 _% h a3 t8 Z% i. G }
" I- p' k2 V) _% o- |/ x+ V }
3 @0 G) L8 U [: m x0 C6 z 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。5 p, T5 [" a* u2 g2 |
这段小代码肯能有两个你需要修改的地方" @/ y+ O& a0 q& X
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键) {) p/ I6 s; c) e* a8 ^# F
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “3 j2 N, w1 B4 Y0 A5 s
|