此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
, a, a- N) ?% P' |: P7 Z* w 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
! ?+ ^6 V+ K' C+ c4 A 方式一:
6 i$ }: {, _5 o& G0 @; @ e' w" ~1 ~ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,) d: r- c4 T7 n+ m
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
) T$ x& s5 ~) u% f% X! ` HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。, R8 E& e, s2 `* M* M) J8 S) I
方式二:
( ^7 R* @& s- a# p5 t& u& s) ~* [ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
" D B, K& L; g+ E1 T/ K SetTitleMatchMode RegEx% b/ i, k2 p o/ A, G4 `- D/ \6 \
return1 }: {$ G( ]) m( i" {" @
; Stuff to do when Windows Explorer is open
! g1 v( \ x" k ;& c* Y% M* t6 O% R. _0 `( Q1 [
#IfWinActive ahk_class ExploreWClass|CabinetWClass+ d3 i; N( O K3 ? M
; open ‘cmd’ in the current directory
8 D% @6 v4 l3 y n" ` ;
/ \1 _8 |- G7 X5 o% y+ M; b# K #c::3 p: k4 D: _1 U1 H8 H. p
OpenCmdInCurrent()7 `7 }' q1 X# Q5 P2 i/ N# x) U
return
8 y. A) ]- _4 M6 ^$ U2 r' \$ e #IfWinActive: C) A. F8 ~2 C+ Q; o" s
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
6 X+ m* e9 _5 t4 t# ` ; Note: expecting to be run when the active window is Explorer.
! x. _" `7 c* J ?1 m9 a. k ;" [0 N) V9 b# x1 ]- y; P
OpenCmdInCurrent()$ `. J g) C2 F; \0 k
{3 v ?: t- ]* T7 O* ~2 e" }
; This is required to get the full path of the file from the address bar4 m1 Q% {& |, I* s- u( Z
WinGetText, full_path, A
. I' i' e/ G/ M: a, ]- B' L ; Split on newline (`n)& ^, _9 ~; P5 c0 \
StringSplit, word_array, full_path, `n
- R9 k Y; z, m3 _: D6 _3 K ; Take the first element from the array1 t9 P2 m/ z7 ?) x, F$ u
full_path = %word_array1%9 [7 Z- X7 \. j4 M% U
; strip to bare address. T$ O3 r1 M& `7 m. v6 d
full_path := RegExReplace(full_path, “地址: “, “”). j9 v. S8 ]$ D/ ^
; Just in case – remove all carriage returns (`r)4 f3 Q9 p `9 I' T4 R, Y1 g4 Y
StringReplace, full_path, full_path, `r, , all" q, P# |, v6 Q0 h, T
IfInString full_path, \
* O4 ]# H4 z$ D {; L; o6 y: g {% g0 }1 H$ s: F: l8 N
Run, cmd /K cd /D “%full_path%”
! ?1 u% C! `1 _% f4 x7 D }% d; |2 J# z; g2 h3 a% a/ O& U
else. i8 e7 ^* i: e
{
$ Z1 }, {- A! X+ Q1 j Run, cmd /K cd /D “C:\ ”
) `- V5 f" j0 h) P$ ? }
! V/ H7 V2 w5 h }
- @% ]: V( W3 z. F 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。9 F! J. |! m$ \$ o& Q2 y6 A$ w1 @
这段小代码肯能有两个你需要修改的地方
7 X8 g6 l9 S! ^6 ?# a; b 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
- Q' m# j5 x9 M7 k; I 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
! j$ p+ ~3 d! Q7 q4 Y. c |