此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
+ }9 u [& B0 A% o 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。5 Q) a' [- N8 D: l% X
方式一:
9 Y( g5 C2 S9 F M 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
. B$ l& Z4 h9 a- t1 E 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和4 C# u e" f$ P. W5 A
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
8 T0 r3 o1 u: v. l! t O 方式二:
6 [' _9 C* J& d' I& G5 K 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
/ S' w. n( R3 e- ~) o% i! g SetTitleMatchMode RegEx
! \: e2 d0 ]7 @ return1 @* W) Z! v: @( I8 W# `6 S$ U
; Stuff to do when Windows Explorer is open
8 M2 z5 W' s8 D# X& c ;% v" j1 z* |. B5 D: {
#IfWinActive ahk_class ExploreWClass|CabinetWClass
1 h8 \8 x/ B' [ ; open ‘cmd’ in the current directory5 e- `2 ^: C1 K9 V+ j4 I$ C4 S
;
6 B& @# Y! L. J# @: z! h #c::' S$ s; t7 d3 M- ?3 R( y
OpenCmdInCurrent()' t' N- y2 f& t+ H+ u& C
return
( M8 A& {# {3 m" u1 m #IfWinActive
6 m0 D4 h' ]: _; G ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.# O7 p# k6 A" ^; W: X' b7 `
; Note: expecting to be run when the active window is Explorer.
* B1 Q0 e: r; W( U" Y! V3 Q6 H2 [: l ;- b8 V' D' V- [
OpenCmdInCurrent(). g) o( r7 r z# V$ @
{- r* G+ U. t0 U+ P
; This is required to get the full path of the file from the address bar. p& N* f6 \$ i. e4 a+ L2 \5 R* z1 C
WinGetText, full_path, A$ v* k9 X( ^* j1 `2 b& S }' N# D, r
; Split on newline (`n)& G% P# E, F2 _* ^
StringSplit, word_array, full_path, `n
! R. K" P4 o7 ^4 E! \ ; Take the first element from the array
* g+ w0 p0 f3 [! S full_path = %word_array1%1 e V( ~$ M( y" _& o; x" G* ?
; strip to bare address1 Q5 w9 C$ X+ [1 F- |
full_path := RegExReplace(full_path, “地址: “, “”), |4 r X V1 T4 j
; Just in case – remove all carriage returns (`r)6 q3 K' u! g. G
StringReplace, full_path, full_path, `r, , all1 I7 ?6 r3 s- h }
IfInString full_path, \: B' d, W, _& N4 N9 N$ I
{- f! m& B) F8 x; }! f a
Run, cmd /K cd /D “%full_path%”8 ]2 r) x/ \+ f0 c
}, O( O! o5 Y& c9 L4 ~
else
2 |- ~8 N$ h+ {/ K. ]1 A; x* L {
1 n) U, D% K3 g1 G+ j0 a; b$ v; C Run, cmd /K cd /D “C:\ ”$ x0 o0 U" T, [. v
}
- w/ y0 F" F0 b B$ C: s* t I; P }
! {( s8 y# h) y. k/ v# g 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
" a6 h* H3 ~1 t+ `0 e5 f0 d" C$ s 这段小代码肯能有两个你需要修改的地方
( U/ P) ~% K8 l O0 k 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
, \5 d* a2 j5 }3 H9 Y+ n8 w8 D 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “. R& w+ x, E% P& c4 H. ?
|