此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。$ t8 L: a; U8 [
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
8 s* Y3 R) G# G" ~ 方式一:
( D: \. \' O3 l9 A2 |1 [ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,2 |! {* Z; g/ o T; x6 w8 K( D
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和! {( o$ F! Y. a' g. t0 ~: T" ?
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
; x) ^! r! h. g& I8 f 方式二:
* J* b ]% D+ w8 K0 Q 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
# n2 W: X- A) K; c6 e/ f SetTitleMatchMode RegEx
4 Y+ J# y$ b b; E, R- ?, i- @1 S. Y return7 G( P* a5 H, u9 D( e& _
; Stuff to do when Windows Explorer is open
2 u$ p D& t2 L" Y1 a) Z' g6 v ;6 Z1 z+ p8 [( E2 F, ~5 }. D$ H
#IfWinActive ahk_class ExploreWClass|CabinetWClass
1 v0 j( V1 b5 {3 X! W. u" `8 V& x ; open ‘cmd’ in the current directory! c. `, d6 L) L v; h H( w$ b q
;0 V# |/ j3 V* {( e4 K
#c::! E& h2 b% {9 i: u
OpenCmdInCurrent()
$ |+ g E3 ~5 S6 ?7 O return
% U" _# h i3 U0 [! f #IfWinActive: \/ H# |# I1 U0 [9 u; _9 a! |
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.! b% p) \) X& D3 K
; Note: expecting to be run when the active window is Explorer.6 B6 ?" r% U% s
;) A# [! k4 V/ R( k7 E Z
OpenCmdInCurrent()
# M3 x" r* n8 ^. f- f {
& n: h- e% d4 K9 K3 Z ; This is required to get the full path of the file from the address bar8 Q9 j ?, T. m) t, l
WinGetText, full_path, A5 Q4 `$ n' A( c& d
; Split on newline (`n)
/ A2 z2 h) |$ g. J* L! N! d StringSplit, word_array, full_path, `n
, P6 _; ~# \7 V" V4 L ; Take the first element from the array- q0 N5 P' S+ _0 q4 m6 L
full_path = %word_array1%
' ^0 r2 Z& q/ C0 w7 }9 y4 V ; strip to bare address
3 |" A/ m8 Z v# W full_path := RegExReplace(full_path, “地址: “, “”)% {! ?4 Y* Q1 i9 G
; Just in case – remove all carriage returns (`r)! V, R& L4 g/ N4 c
StringReplace, full_path, full_path, `r, , all
! O7 x: M0 N4 t2 A* ^ IfInString full_path, \
% Q7 @ ?; E+ z& t3 g/ x" d {
% d6 Y$ R- E$ U Run, cmd /K cd /D “%full_path%”
# v+ G8 A3 T9 v5 g* ] }
3 q$ G X9 @( N* T3 s U; c else! E" Q# W; @: B& I/ x
{
5 M, D9 r2 }( ?3 K. b$ `/ w9 z Run, cmd /K cd /D “C:\ ”
k$ y5 A0 V. v+ N8 m }6 w: a; _7 A3 H- H0 D& F1 O6 F z
}
4 F x# z3 [; f/ t 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
. k" d/ n2 e z( y! z 这段小代码肯能有两个你需要修改的地方1 l- f4 \9 I' e+ f- D
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键4 t% A! m$ y! | }
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “- k% z$ a" J; ]
|