此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。8 `5 X( n; N$ E8 L! {# L9 O' D
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。! P- v( y6 }8 x( h, Z9 Y1 Q
方式一:* F. p+ _6 R4 A8 Q0 A- c
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,' G) c8 E) J* K0 F4 i8 E( n$ @4 X
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和5 ?. p' i, j3 f; O
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。; |! V9 l8 _3 @, s
方式二:/ C0 _- A: c, `
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:/ q L& Y* b Y- R5 \
SetTitleMatchMode RegEx. p! o* q1 t3 g$ @( {
return
1 L' a! V$ H* X. |% E& j' A ; Stuff to do when Windows Explorer is open( z# |8 k6 O* U" u- K4 x2 `4 R2 Y" j
;
, @0 r) A. t" Y$ s #IfWinActive ahk_class ExploreWClass|CabinetWClass
: t+ ]2 h! H% { ; open ‘cmd’ in the current directory
, M; q& v7 p9 Q/ q6 \5 o ;6 L3 ]2 w6 ]& Y
#c::
/ N: x9 Y* V# j' v OpenCmdInCurrent()
5 K4 ]! Y3 O+ `6 ?7 V return* V6 o$ P/ M0 {$ c' g
#IfWinActive I" K8 b+ _6 u4 M/ r
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
: D" s4 @- Z; a3 ?1 l2 W7 j ; Note: expecting to be run when the active window is Explorer.
& i' B7 s* e D* v6 Q# I ;
2 n5 ?% A6 ~0 O/ ^) n" E OpenCmdInCurrent()
3 l6 y% z* Z: T1 z9 Q {. j B. ?1 n% i9 t0 @
; This is required to get the full path of the file from the address bar. X1 c+ Q! M! f4 t" N
WinGetText, full_path, A9 q+ R( G: L/ G
; Split on newline (`n)
3 W t) m1 ?& q1 v6 E: K StringSplit, word_array, full_path, `n+ A5 M+ I, k9 C
; Take the first element from the array& Z) H w3 n. A
full_path = %word_array1%
* {8 D* ] d& |/ \ ; strip to bare address9 |. m; u2 ]0 e. L% Q* o
full_path := RegExReplace(full_path, “地址: “, “”) V4 N) U" t: \9 c& A, T& @) }) R
; Just in case – remove all carriage returns (`r)* _/ \# n3 {: m
StringReplace, full_path, full_path, `r, , all
9 d0 ~6 C7 D" }2 _ IfInString full_path, \( [- f$ a# \- D3 U! D: n
{
9 e. r: _' g+ K& [8 i Run, cmd /K cd /D “%full_path%”
9 V# ?, K- O3 D% b3 W }
- g8 `+ X; x1 | else
1 u0 }$ v, Z% r2 v4 T {/ {' ]+ B9 w' y C+ }! O2 {9 f5 B
Run, cmd /K cd /D “C:\ ”- e" G2 a7 \& F. Q
}
' j, i+ B9 e6 d4 Y' a }
9 }8 s! X5 N( |. N 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
. [; d1 e$ X7 M% w( s/ g- j 这段小代码肯能有两个你需要修改的地方
7 H' J8 z& l3 @$ ?# H 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
. V, O# F- g& l+ f 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
+ g/ D! o7 M3 _ |