此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。6 T$ O: u- C) x$ S% r* Z
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。( b4 g7 v( x9 h. ^9 v( ^6 w, p
方式一:* @. q2 k% R% N- Z/ S: o& @! I8 d
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表," ^/ }- C4 k' r5 |1 \
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和9 f1 s# r$ e$ B) J2 Y, k" O N
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
( t J& l3 a- s. S( s+ K 方式二:. W, w9 A {' D7 D1 D7 A' a
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:$ P# d, G- d, o' e5 H
SetTitleMatchMode RegEx
* ^; o3 N8 L5 H8 l; i) S# o return% H) d, Q* j) `
; Stuff to do when Windows Explorer is open
, h/ M+ U/ d* g* b( c+ {( E( h2 V ;
3 |/ [4 x4 ^; ?! N) X4 L& ^ #IfWinActive ahk_class ExploreWClass|CabinetWClass
5 j9 a/ E5 w1 S; C, z# D' {. F- x ; open ‘cmd’ in the current directory
6 M: i$ b! S) K) g" V5 }, q ;- X7 u e/ A2 b2 z$ i
#c::/ k$ o9 E7 Q$ p& R. i
OpenCmdInCurrent()
1 F" G" s8 I+ Z5 }2 B return
' I5 x, D. n, n. O7 }8 k; V5 X #IfWinActive
- c1 c# i% q& t6 z ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
8 _ p& _+ f7 e ; Note: expecting to be run when the active window is Explorer.
: C9 `5 ` K) q# q# q {% a ;
8 N4 c! e, {$ ~ s OpenCmdInCurrent(), F/ K1 Z) J: D/ h
{
7 t6 r1 U% B. V' [- |' h6 B* n r ; This is required to get the full path of the file from the address bar- d1 \3 t0 f" o+ y' [3 Z5 ?
WinGetText, full_path, A
2 n( s' P0 g; c% N& }# A9 Z ; Split on newline (`n)
$ H# \# n& A* C% ^4 e5 Z StringSplit, word_array, full_path, `n7 c/ _1 N5 d, F$ o8 W5 U" D
; Take the first element from the array
" I! z* {$ }4 A- m1 B5 u8 E full_path = %word_array1%5 ~" K( j; K. n; i, r3 t
; strip to bare address
$ |3 e2 H9 u1 c: d$ v) w7 M5 g/ y full_path := RegExReplace(full_path, “地址: “, “”)
' R* |% v l8 P8 _5 W1 z' j ; Just in case – remove all carriage returns (`r)
% Z7 G- q; U% i0 q; S0 U StringReplace, full_path, full_path, `r, , all5 ] a+ }. S; r e
IfInString full_path, \0 y9 h( ^1 q1 h7 V
{
4 h8 S3 h+ U: J! A Run, cmd /K cd /D “%full_path%”5 ]8 a5 [) w& z
}
- @( N; ?4 _5 z1 i( r else L* e% C& b$ z }3 t% g8 @
{* D! i. d7 A6 m1 R+ L" G
Run, cmd /K cd /D “C:\ ”# I1 x! g0 H# Z( ]- p! V
}
: q$ @; A) O$ z- V1 K }
$ F' K0 m. M& n9 Z( q 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。7 `( j; j5 i* ]9 V+ E
这段小代码肯能有两个你需要修改的地方- ?! m$ F8 X8 [2 H. p
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键8 d+ ]7 [1 N7 g3 e3 i/ B9 b
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “5 B. ?- n& u+ t2 a1 [' c, c5 ?
|