此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
) w+ b/ K' D% M 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。. ^% J# s& G( t4 K' J* T
方式一:1 } }% Q, M1 g& _3 n3 I; c' f( ?
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
$ @& W) `% _# c% w 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
( m; a+ n; E; |4 | m8 ^ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
6 J8 V; ^0 X# ~ 方式二:5 J# s. U5 X: B% y' f* ?8 b( p2 N
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:! ] {* x5 q, Z7 y, V
SetTitleMatchMode RegEx
/ @4 H' k" {, I% O$ G5 ]! v return
, ~. V/ @9 _ j" e2 k ; Stuff to do when Windows Explorer is open* B9 j6 Z% G$ v+ q% r# y5 Z
;9 a, y& p: ]3 Z1 a
#IfWinActive ahk_class ExploreWClass|CabinetWClass
$ v( u& @( y. u, R3 Q ; open ‘cmd’ in the current directory3 L7 ~& c, Q% \; k
;
. u9 B6 b3 o) B5 P3 l #c::+ U& I* S) h. V$ ]& a
OpenCmdInCurrent()% E* A4 j% r7 t7 H' g7 V0 e) g
return: a# B, h5 M4 g, t+ N2 S* E6 T
#IfWinActive1 q6 ]7 v( Y8 q7 t4 _. \
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.$ I# ]/ d2 |! M6 f4 A
; Note: expecting to be run when the active window is Explorer.8 h/ P7 _+ v, n( F p7 b
;7 q1 u- h! V) C: r8 b! Q. {( W* N
OpenCmdInCurrent(); T) y% n- n% q& b
{
$ T) W' A) N8 }! f7 e ; This is required to get the full path of the file from the address bar
- c7 ^4 A( [3 ?2 J; ] WinGetText, full_path, A
* L( a9 [/ N- `; q' n) Z4 O ; Split on newline (`n)
4 F- U; M- u/ s5 v9 } e+ ]; F E StringSplit, word_array, full_path, `n
. f M1 ~- t- N ; Take the first element from the array7 i; v& g9 D. F* B7 f0 Y
full_path = %word_array1%9 o5 C! v+ j# [
; strip to bare address
( [. `7 Q2 a A full_path := RegExReplace(full_path, “地址: “, “”)3 f/ F7 l3 @5 F0 t
; Just in case – remove all carriage returns (`r)
: b6 T/ ?/ Q- E9 K StringReplace, full_path, full_path, `r, , all
6 I- w+ i+ S# x4 l IfInString full_path, \
3 k' q* j( @) M6 ^9 Z {
3 C, @6 T& B" Z5 b9 `0 ? Run, cmd /K cd /D “%full_path%”
4 B( O1 c$ Q& H* t( m& y }
2 c$ n5 M9 `/ ~9 \( f* X else/ D, g [: }0 h7 m* }6 m
{
' c% X5 O: v3 C0 _0 r9 v b Run, cmd /K cd /D “C:\ ”
7 [: @) b1 m* D. B' V4 k0 m: ~5 B }0 l! i$ G1 `( R5 B
}" q* S" @0 K, Q, f) Q( ]
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。* C6 r" {# s% Z: T. i2 ~# a4 e
这段小代码肯能有两个你需要修改的地方
3 ?& l' W% K* Q6 Q! b2 S 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
& z) Y) H, h m' X' w5 w- y 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
. f$ C. T1 m! g1 s) E. `1 [, t1 X y |