此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
% V& f S" ?7 n8 j. f7 d 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
1 p" S8 R- ?/ v* D4 [ 方式一:
' Z" e' z: i6 L' D- z$ {# E I 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
C5 z3 u) F9 Y5 O3 L( ] 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
5 i% k& S) @* O; J, K9 F# x1 ` HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。 i& x! E; o! O) ^
方式二:
# p0 `6 e; q# B' k: ^1 a 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
' D8 }: C H: | SetTitleMatchMode RegEx
( }# P' U. L% }, j C) A" {8 @ return% ~- z1 S8 Q( ?+ @- E
; Stuff to do when Windows Explorer is open% c& p7 f7 A2 G3 v; J1 X$ z9 E
;
j1 h- C v" n, y4 Y #IfWinActive ahk_class ExploreWClass|CabinetWClass3 ^4 M! X) C- z) d4 T
; open ‘cmd’ in the current directory. S2 U" w3 r9 `2 e3 O
;8 i7 f8 A* Z$ F' v9 l! k) a4 E
#c::) u* k7 y1 x6 U9 z' ^( N
OpenCmdInCurrent()
7 @& m+ x C# h9 \+ q, {+ R4 l return- X& M' z8 z- O. @ G5 r
#IfWinActive& |) Q3 a& w, @
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.2 z' O" _/ E/ n4 I2 g
; Note: expecting to be run when the active window is Explorer.
- k" U! x! U. I9 Z# F0 S ;, n6 w% \* @% W8 f0 Y5 y. ~/ u
OpenCmdInCurrent()
+ q7 s- e- c$ P" w! Y8 Q# Q, N# _ {
- v9 x; m' u/ i2 { ; This is required to get the full path of the file from the address bar2 \# E0 V; a0 y5 V3 t
WinGetText, full_path, A* W8 u5 X1 W }
; Split on newline (`n)( Q3 V* `. \( E- w
StringSplit, word_array, full_path, `n
* Z0 Y0 }! J- Q8 }2 N ; Take the first element from the array8 b; c- |/ A5 Q, F& m6 Y
full_path = %word_array1%. t" Q" \2 ^+ A. N4 o
; strip to bare address
% \3 b3 u I+ X3 Z$ G full_path := RegExReplace(full_path, “地址: “, “”)
1 w8 O# O, I; @8 A- C+ [( H6 c ; Just in case – remove all carriage returns (`r)! h: S7 t _" l" \& m8 u' T
StringReplace, full_path, full_path, `r, , all
8 m! d9 [/ c0 K7 m) |) U+ h+ e: h IfInString full_path, \5 a! W p- y3 M: Z; r8 q
{5 Y1 c- L+ q, y) c3 [4 `
Run, cmd /K cd /D “%full_path%”
: C% y' x8 S3 b1 w& w# G- ?; K# v }+ k" ^* u) r+ |) j/ A- X
else
, O/ l1 k% w! U {
! V& {: d( p( b Run, cmd /K cd /D “C:\ ”
5 a; s7 f# B/ P4 r! Y+ Q }1 h& U4 T' X0 y/ K, L4 t
}7 Y0 \+ d' B a0 O4 U( j1 N) @
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
" J2 N; ]9 G7 B: G 这段小代码肯能有两个你需要修改的地方
! L, j# C# H: e1 h, m# A( Q 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键0 N: i+ P# \' x4 f0 D4 t9 v3 E
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
" \ W& u3 S; s# i- v |