此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
7 n3 r8 c8 q* O" @: J: ? 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。* _" O, f$ u: {' z: v
方式一:
7 r: s( f9 {0 j [( s* V. H2 c1 x 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
8 V# H, p3 h" W# @ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
+ T- o: ~0 ^& A" z HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
$ x4 @, [1 ^; f! `9 i" U3 W 方式二:
, N, n5 I1 @3 s& d o/ p 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
& h3 Q- C5 S& M1 m6 C, v SetTitleMatchMode RegEx. P, ?( _9 B; a4 T7 x' R8 E
return
( p+ {# y9 [! P( C8 ~0 m ; Stuff to do when Windows Explorer is open
' o. M+ A4 Z0 q) I/ I& `) O ;3 g' [: |. K9 A: p! X: _# g# g
#IfWinActive ahk_class ExploreWClass|CabinetWClass/ F0 E& |- o. r
; open ‘cmd’ in the current directory S# M; ]2 M M7 l2 j: b& F& F
;
. A* E3 V5 j( Z #c::8 I1 ], U) o3 X/ L, T
OpenCmdInCurrent()
& U3 D) g1 q" [: F( q' U6 r& h return3 D1 T' B" K+ M9 S- b, Y1 G
#IfWinActive
, }# P' z) [; u3 x" o; A8 I ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.7 X* w s. T5 Y, n6 V2 c% _/ Q
; Note: expecting to be run when the active window is Explorer.
% k7 _( {5 N) r _! X5 l4 @1 f6 v# L* ^ ;% s' P7 H& T# x1 z
OpenCmdInCurrent(): S; l0 z8 v' k% z' ^- z5 `
{" H8 L+ @4 h: Z3 u& \ o
; This is required to get the full path of the file from the address bar7 Z" S+ L3 p8 l9 c% q
WinGetText, full_path, A4 y/ |* H/ W9 P* N/ A" w
; Split on newline (`n)
% H" i* Q* L3 Y; ^6 T StringSplit, word_array, full_path, `n
5 D2 W7 f4 b' Q ; Take the first element from the array& p( N, q! A: J# F: h
full_path = %word_array1%; \6 ^2 D. J, k
; strip to bare address: E; |- `# P1 ^0 t c- _9 O
full_path := RegExReplace(full_path, “地址: “, “”)
3 D* M3 l$ f7 k6 }. c: U3 J% t ; Just in case – remove all carriage returns (`r)
/ |( ~3 x; H) e7 }$ ` StringReplace, full_path, full_path, `r, , all
: C5 t! e2 e2 | IfInString full_path, \0 S- @+ T4 D" w% y
{2 y( k" {5 V( E8 I
Run, cmd /K cd /D “%full_path%”* D& @ z' g( K+ s$ x" f ]8 a8 N: q
}
0 i+ }4 U2 X, E9 l8 p* g" a else
% o2 R* _2 E- c1 e {
4 @3 E" C( c4 }3 l8 n Run, cmd /K cd /D “C:\ ”) e- B+ _6 D; R+ O& {1 ~$ R
}
- b( y/ Y# r7 S4 Z }/ I6 E' ?" j3 D' h, z. e' W! M) a
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。1 v$ F- |# ?$ S6 H
这段小代码肯能有两个你需要修改的地方3 b+ ]) |; I7 A# Z7 `
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
* c: D$ j7 b0 m5 a2 _ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “- n7 K, z: x1 Q8 b+ s6 C6 o
|