此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。- q; k0 x2 V/ I, v+ q* u; I
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
7 J* r D+ X: Q- o% y( s, ^1 T 方式一:2 `' o$ Z7 R9 G1 Z6 o
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
1 U9 b7 p" Z4 L6 r( D K 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
O/ R* D3 N% \# H* L HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
; [+ t* p, g4 r0 M; T: e 方式二:
' ?7 n1 u1 o$ e8 k 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下: E( V% y/ Q$ S3 i: [( V
SetTitleMatchMode RegEx
* [/ Q) U% y4 `3 e9 p return% y& r0 _7 U, T- D
; Stuff to do when Windows Explorer is open
" d0 a% p: v; l$ p ] ;4 m# T! T" t& \* Q
#IfWinActive ahk_class ExploreWClass|CabinetWClass, e4 P$ g1 r0 J8 m
; open ‘cmd’ in the current directory' O; m1 z/ E" A; ^$ Q
;
7 d; G0 d" p0 t9 T #c::
) y2 o) t0 E" q" R5 U) @0 J4 F' e OpenCmdInCurrent()
4 x9 M8 z4 e) d! C0 P return
, A1 _ ~; q- c- n* N+ d7 i #IfWinActive% F/ n/ g2 D: S+ a+ P
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
/ H) J/ |) S! `: _0 d. I/ I# p& P! u ; Note: expecting to be run when the active window is Explorer.+ p3 n6 @' K/ s" |" ]. [
;: f/ L7 w O7 _( _- e; O
OpenCmdInCurrent()# Y/ f. N5 c' P' r' ?7 e$ T
{' {5 X. |7 g# w* K5 H$ K8 s
; This is required to get the full path of the file from the address bar! ]! K: f4 C& r
WinGetText, full_path, A
T2 K) v7 `; r8 b( r ; Split on newline (`n)6 J; w& J6 K3 V+ Z/ g* Y
StringSplit, word_array, full_path, `n# w4 I& `6 u! j- E/ }2 H4 d
; Take the first element from the array
8 ]: O, r7 l/ @) F- o full_path = %word_array1% p# z" z, W0 q+ c3 m; q8 Q
; strip to bare address
' J- [9 l8 L' W% ~) C. W full_path := RegExReplace(full_path, “地址: “, “”)
$ x. s: W2 g4 Q0 T$ x. x, I ; Just in case – remove all carriage returns (`r)2 n" t, { D& X$ n* S
StringReplace, full_path, full_path, `r, , all& C; t8 w" b2 ^+ _2 B1 |, _+ `
IfInString full_path, \1 m3 H/ {( N0 @- d; X, G: c+ A
{) F W& x. l( M) s
Run, cmd /K cd /D “%full_path%”
) w$ r+ A8 s: F }
1 G( M8 l/ c6 s else
7 ?' U K( o) o- N1 }8 N0 d5 e {, y v- W. Y1 Y% G/ L0 I& @
Run, cmd /K cd /D “C:\ ”* | T0 L# F+ F4 |% ?8 h1 X( I
}
$ P" l! }9 {- P! S$ p }) d" _1 b e* l4 t
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。# G+ ~4 s9 x$ s: X1 t
这段小代码肯能有两个你需要修改的地方
9 k7 s3 N9 l5 F8 O. C: u& v5 i 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
; Q) W! E' W5 d0 _ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “; I0 T) x" m6 k; B
|