此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
8 q j: ]! U7 N* S8 h- u4 l 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
$ n+ m% S2 d( A7 U 方式一:9 v9 K" O8 G% z! I7 u* f# n, f
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,% ~) Y- r7 R, x ?9 M& R: T+ O( {3 Z
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
" c. q" ~4 \% W, g HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
+ q: C5 |* I3 F* j 方式二:
f3 i* X, z) Z4 V" |4 d: } 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下: z! a! p& t) w# @- g
SetTitleMatchMode RegEx; J1 m5 a1 T( G; q4 i
return0 q2 I; g; Q+ a1 `
; Stuff to do when Windows Explorer is open
$ K, d0 l2 s J! v S. ^ ;+ s% k# h4 o1 f' v4 k
#IfWinActive ahk_class ExploreWClass|CabinetWClass
9 ?2 J+ c- E5 |3 ]; Q ; open ‘cmd’ in the current directory
) V: ]- s U2 E! A ;
/ b5 E5 i% ?' v ^- d, ~ #c::
' z$ o5 l5 z# X" t( o; R* u OpenCmdInCurrent()
$ ~# h- _3 Q3 ]' C" b0 U9 _1 D/ i return. F$ o# h- E1 F/ o* M! h
#IfWinActive
" A0 Z; {! ^9 d i4 q ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
/ { D& _# t# R3 y2 f1 d( F- e ; Note: expecting to be run when the active window is Explorer.* z) @' N# M' l% U
;1 u4 w6 Z4 E7 u, D$ i7 }
OpenCmdInCurrent()9 q2 N4 ~4 {* n& p
{: m# M# b+ }, O! U( m6 b
; This is required to get the full path of the file from the address bar
: p- r" B* m' _. p WinGetText, full_path, A0 R0 J$ C) A: } m5 b, y) L" K
; Split on newline (`n)
9 @- j+ [' s$ A; _ StringSplit, word_array, full_path, `n
) c$ X1 w# {! B) W4 C2 @ ; Take the first element from the array: g/ ?6 o1 k& x, \/ u' K F. D
full_path = %word_array1%
3 [& b1 k1 a, v' I( j% }) b3 r ; strip to bare address' T y7 Y/ S; R! U
full_path := RegExReplace(full_path, “地址: “, “”)! v, \9 K# ?8 I& h* {
; Just in case – remove all carriage returns (`r)
! e% T% y5 u- H7 _ StringReplace, full_path, full_path, `r, , all( Z. P1 n6 }7 ?; E. Q/ K
IfInString full_path, \2 r& ~2 {( z Z" C
{5 B( M7 u+ H5 Y- ]' k
Run, cmd /K cd /D “%full_path%”) v, b; C( k6 V
}' c6 e. {" H0 t7 ~/ N0 A& z& P5 I4 [
else
( g6 {+ E; q0 f' x4 H {
+ d, V/ Y9 W$ n7 @ Run, cmd /K cd /D “C:\ ”2 q2 h" K' r. p' }
}& F9 B, d) c5 Y5 g
}
5 J- t1 [2 b2 |9 m/ T" q6 u1 ` 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
( x$ F6 h% E7 }8 v0 r 这段小代码肯能有两个你需要修改的地方+ e! W& }. p7 T; p
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
+ d7 N! y1 `8 ?; } 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
4 f9 K8 C& d$ ^$ d |