此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
) _0 \, B. O. f- c 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。, q+ b8 b) r% M2 c% B- z- H
方式一:
2 \" u% C# c& s+ f4 E5 ` 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,% G3 c- T: `' \; w8 I
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
. s3 g3 \; x( Q( L9 ^) x$ {& W; p HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。9 f' {8 c5 a" c w
方式二:
, I% _2 c- m _5 Z5 _! z# ^; q 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
/ }, Q) R6 @& ?0 ^( r# l' z% a SetTitleMatchMode RegEx9 Q0 [9 a: |' [! @- ?8 i
return" y$ ^) Z( H" L( v# {
; Stuff to do when Windows Explorer is open* N- S/ c% p" P: k O5 N
;
, M h$ G2 L4 ~" {6 i0 p; }0 I1 x #IfWinActive ahk_class ExploreWClass|CabinetWClass5 `2 l% f8 R& _8 `
; open ‘cmd’ in the current directory# l0 f& o8 }& L
;/ x. b4 I& M7 D. t
#c::
. s; B9 n/ K/ f1 d5 y OpenCmdInCurrent()
# G( }2 H' W* E( k# t9 D return
' ~) j5 x0 a' R$ Q5 k #IfWinActive
6 E6 G- D- N4 h% Z) \1 U ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
( M2 w" i9 M" e" x& O5 h ; Note: expecting to be run when the active window is Explorer.
- K2 u5 K; w' K$ j' n7 h" }; n/ s- F ;
0 k h d: g5 ^4 ` T- i OpenCmdInCurrent()
2 ]3 A- J$ l. Q: O. |) r {3 a% I# q R4 d) _+ P6 F* V
; This is required to get the full path of the file from the address bar
9 M/ N0 s4 a0 y" R/ r5 h! V WinGetText, full_path, A" r2 C% o O7 o
; Split on newline (`n)# w' V: s+ g* v; j# _) n! B
StringSplit, word_array, full_path, `n7 M. i$ H$ c7 N8 U7 z& U* Q T
; Take the first element from the array
9 K0 Z- N( a( }- ]) I9 F full_path = %word_array1%
! b6 ~% |% f2 B: o9 k5 [ ; strip to bare address
0 T" e2 Z" t8 N8 e' G5 r- L o full_path := RegExReplace(full_path, “地址: “, “”)* |* z0 X: r3 g' W' r
; Just in case – remove all carriage returns (`r)/ a6 \, f: e# j4 h/ P" I- R( r
StringReplace, full_path, full_path, `r, , all& O! s0 C1 @& @
IfInString full_path, \
8 i' J$ V9 h0 N6 G4 }3 `' K1 [ Y7 X {
' l$ A) N8 w0 ^6 m* M6 T' q% C) j Run, cmd /K cd /D “%full_path%”
, T# X# ?( B6 C1 j4 t' ]. d# C* h }
0 R& }% X s5 p( t0 L else1 e) V" _$ l2 j3 N; s/ I
{; `8 ]$ x: w3 f4 Q
Run, cmd /K cd /D “C:\ ”0 B. d9 O) {# t' n2 M7 z; a
}( k% z* U# v2 L0 ?4 D8 K0 F4 a
}
7 i( ?- A$ d+ I7 s$ P% W* m' K 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
W6 ~8 Z' F# @$ b4 o 这段小代码肯能有两个你需要修改的地方
R- N$ f$ O7 Z: k1 A3 w 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
4 B: ~& S9 ]9 H8 y( ?: e! I 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “! `- ?* Z* ^* n% I! W6 Y
|