此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。4 X# m8 I; D& Z) s
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
% O0 o7 r1 F+ q- e% V 方式一:
4 r; v0 @2 F; }. e% C 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,; X/ G9 E$ ?% |% C2 S3 }7 [1 Q
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
/ b/ y7 [ w1 j9 W HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
, Q3 `, Z- r, {7 y K2 J% X+ @1 D 方式二:
5 I1 h& ?# M; U% G$ @ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:) D I# V$ j# O# `, L# [) ^
SetTitleMatchMode RegEx. e* R& W" z5 G7 l, C8 C/ j
return
* c1 M/ M. U, \% p ; Stuff to do when Windows Explorer is open
# W7 R) u3 e6 k1 V# n4 r ;
$ Y( ]7 w5 o9 e6 H$ t% m9 x #IfWinActive ahk_class ExploreWClass|CabinetWClass
" C" {* q0 K, m5 Y7 p4 v* \ ; open ‘cmd’ in the current directory; X- @8 o0 b2 Q: S% K$ h, B
;/ g; C+ K1 O- r+ |0 ^; p: f
#c::
2 E5 s, ?" h% f2 L OpenCmdInCurrent()
1 N q" V0 F; N return
) q1 O9 v# q7 a f- ?1 v; P Z3 A #IfWinActive
" Y, q; T+ l6 w4 s9 \8 `$ r) J( k ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.9 e2 G; ?( a M9 t
; Note: expecting to be run when the active window is Explorer.
4 K& o% i( A" ]/ y ;, o" I" a' b& I
OpenCmdInCurrent()
5 ^, x R% ~7 w; v {! a9 {2 c5 @) t i
; This is required to get the full path of the file from the address bar0 J5 L2 J" q. v5 C
WinGetText, full_path, A
. @6 [4 p" I7 _4 |- o" O7 x' ^" Y ; Split on newline (`n)# r' d j. Y, N2 n* v7 W* _
StringSplit, word_array, full_path, `n
7 H+ I% b' w X0 a+ H ; Take the first element from the array1 S* I& n: a) Z( W/ t, [' Q
full_path = %word_array1%
4 f6 B$ {/ n. O9 B ; strip to bare address; F3 U6 t! o. c* q1 X: L
full_path := RegExReplace(full_path, “地址: “, “”)
0 t- \/ L# w+ s& ^ F+ G ; Just in case – remove all carriage returns (`r)
U$ @! X& ~% f! |5 h5 u StringReplace, full_path, full_path, `r, , all
; k1 j+ O8 r$ Z9 L4 M IfInString full_path, \0 e; e7 Y f) K1 E) u9 \, ?
{
/ M* {) ?0 T2 C$ I Run, cmd /K cd /D “%full_path%”
8 k5 i8 @7 m3 L G l }+ f8 W2 I; J- ~, Z3 V/ [
else. A/ H1 s& x9 C$ q- A' }
{3 D$ Z- a. F6 v% D* u. W
Run, cmd /K cd /D “C:\ ”
* o( o# g6 o4 i4 ~1 |/ m% ]" l+ D }
4 B) i* b) Q9 F q' S- p; Y& d }/ }+ {, w, X4 L3 c
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
% @2 [- t& x1 g( h1 h 这段小代码肯能有两个你需要修改的地方
" _% W7 q/ G/ `5 ? 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
X1 m. x7 O4 ~# H/ v: | 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “5 {, c* F+ ? w# @& ]* }! F& q
|