此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
2 f, x& q' Q6 {, v, k 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。& W7 A5 g% u6 u8 j% l# h2 u7 D
方式一:
- V" k! e& ?7 l6 O$ n 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
& `3 B, T: E& m3 K 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和) t- K. s6 P) B1 ?5 M6 v7 o
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。8 W$ t# p' Q! @. f4 T* L# r% X6 i
方式二:
- b# J: c3 v1 F: t3 W 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
1 E. x J' M* [! d* d$ X SetTitleMatchMode RegEx; F' w% G& W9 P0 K' }& b3 Z" _
return
4 I- B: Q4 \4 R ; Stuff to do when Windows Explorer is open) J6 X& A e. a x* D+ O t" Z
; O& L4 d6 a/ s: @; {0 f
#IfWinActive ahk_class ExploreWClass|CabinetWClass1 s7 P: I# e/ |" [/ A, P! p+ J0 ?" t
; open ‘cmd’ in the current directory$ b8 ?" V7 B* n6 a: Z; d
;2 `1 J- G0 [5 {2 x) {
#c::
: M# O4 x* E4 \* Y5 \ OpenCmdInCurrent()6 I# J) K$ `8 K( x! H# Q
return8 ?# q. f" Q4 y+ f' }
#IfWinActive
& G$ X2 F% Z% ^, a ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.2 L/ ]% ]3 A+ Y( Q
; Note: expecting to be run when the active window is Explorer.
. Q. Q, Q! ~3 l3 Q ; U8 f: V6 g/ x6 J3 f
OpenCmdInCurrent()9 `4 n# T, y, e
{) c. E" o) i0 ]6 L: @
; This is required to get the full path of the file from the address bar
! d! j! w) ?2 I# ^/ y! ?- | WinGetText, full_path, A
! Q0 x; g2 _( r ; Split on newline (`n)
7 B: |5 [5 a% H: a1 h+ i1 ` StringSplit, word_array, full_path, `n
4 V4 ]% Z! P7 Y2 X' ^; c/ I ; Take the first element from the array
! H2 o# A6 E2 G) n; X0 j' ? full_path = %word_array1%8 _+ Q4 Z+ `% }7 E: D1 ^
; strip to bare address( r5 S4 J0 j8 ]! ?+ s
full_path := RegExReplace(full_path, “地址: “, “”)9 w7 w$ P( I7 q$ y0 d
; Just in case – remove all carriage returns (`r)- S; V% h7 b: I# L' x: ]9 O( F
StringReplace, full_path, full_path, `r, , all2 v' _1 M2 Z; E! d: w! b
IfInString full_path, \) m7 x( A6 O2 F9 E
{
% x* M u T- \ Run, cmd /K cd /D “%full_path%”6 {3 c E2 W! S* {+ e- y7 o2 x, W s
}
/ E4 N1 Q1 n& t; M" p# F else- f: _7 L$ {; p3 R# C7 N
{
\' h/ {* K9 I, i v/ e Run, cmd /K cd /D “C:\ ”. j9 o3 I" g! R8 B) \
}: z1 V g: g [% a/ h9 j% N% s
}
7 k; Z: i, u# o9 M% D 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
2 Y8 U7 |8 v3 ~* B9 h 这段小代码肯能有两个你需要修改的地方
p6 D, {: o% P' ? 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
- z7 r: _( ~) V3 G9 S 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “! a. G1 S. O! N$ e' }
|