此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
* {/ ?6 ]6 t0 o0 I 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。+ H6 b% G* m6 K0 P' S
方式一:8 M" s( x$ _# x" m7 H- i5 b2 O: m
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
5 y2 L; W% W3 B 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
( Y& i/ M4 @- U0 ^7 {' d HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
1 \5 v Q, {0 P5 W 方式二:
( B, J0 i. F- Y5 C$ \4 N0 i, B( C' J/ J 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
/ }9 v. e6 z2 D2 s9 h1 O% w SetTitleMatchMode RegEx% H- g7 a! b: `/ h8 j
return
9 |/ D' g# T' u9 p ; Stuff to do when Windows Explorer is open
) f' a" }( s& T ;
1 w: R4 w. o! S5 V: K/ R( K #IfWinActive ahk_class ExploreWClass|CabinetWClass
( `. @" ?$ v X" J6 T" ^! ^ ; open ‘cmd’ in the current directory: N. d% E; e2 H, p6 |1 d8 G
;5 d% ~# t# L* I: \# U2 T
#c::% } V* `( a2 y2 x
OpenCmdInCurrent()
- D A$ h, D+ j$ V/ p! n& R+ S return
: O( u; w6 ^! J. _& l #IfWinActive$ g- C9 V# p; V
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
3 B" u. J4 f% ]7 n. P0 n( Z6 R ; Note: expecting to be run when the active window is Explorer., I; k: p& a X; J; x: I
;
9 L1 T8 f# h) y7 u. r OpenCmdInCurrent()& l% }1 j( o/ c: A' t& R+ `' D' x
{: k H: l& Y" G3 m
; This is required to get the full path of the file from the address bar
9 ~; s4 Z$ J$ U9 j WinGetText, full_path, A3 u1 W: Z4 U7 O; H& }# W
; Split on newline (`n)
9 u$ p1 Y& g3 L4 u5 B! g+ t' _ StringSplit, word_array, full_path, `n
) A2 [# x3 V" n! W' G& |$ g2 ~ ; Take the first element from the array
) H: N6 D' v) ~( D2 z+ i2 v1 n full_path = %word_array1%
^- S5 T0 q- V4 V' U1 m) Z! R ; strip to bare address
# t6 o) m) @5 M$ F# Y, t x; M) H full_path := RegExReplace(full_path, “地址: “, “”). a" [- F% ^+ Y% c* C
; Just in case – remove all carriage returns (`r)7 X! T5 m7 a$ c, Z- f
StringReplace, full_path, full_path, `r, , all" x" G2 W; u, R+ V$ ^: g. [1 j4 j
IfInString full_path, \
+ t! C+ e9 ]0 _& v {
9 i0 ^& E+ T) z8 H' g& J Run, cmd /K cd /D “%full_path%”
& W+ E' v3 [ J }
, G( O% ~7 [ m* P4 ~ else
8 D$ i& e+ Z, w' A0 c$ X+ z% E {# `- X: u, o2 L3 x, \7 _
Run, cmd /K cd /D “C:\ ”4 ~0 i$ d$ w5 d" B' U
}
# u) Y7 v* O7 s6 x }
& C- h1 g- |" ]; s 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。3 z5 E. u# b+ ]% ]2 J) m: h$ w
这段小代码肯能有两个你需要修改的地方0 R Y4 Q, [8 _
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键 @- ~' d. A8 N
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “3 Y! {# k) s8 D4 L" B
|