此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
0 @7 }* l/ j) ?/ B9 p. Q 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。$ |& _/ q# S0 {) D7 U
方式一:
+ F) Z% `* S2 e g9 k 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,& B* a9 M3 v* p+ d: {" F
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
. }) l) g$ _: m5 J HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
. i# [0 s2 ]# N7 Z9 U1 A 方式二:
. V/ {* R% k# f; g" l) _6 _ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
* n3 Z- I! I; H9 s SetTitleMatchMode RegEx
# @6 Q3 I" ^2 n5 Q return! [, T0 ^9 i5 m r- T
; Stuff to do when Windows Explorer is open; U1 C$ S# [, C7 C7 D" O" a1 H% z( c6 c
;
2 J# N! i5 d. [3 o. m #IfWinActive ahk_class ExploreWClass|CabinetWClass
2 k- q5 A9 @- k! v7 S* Z3 v ; open ‘cmd’ in the current directory y# k, V% U, E& [; D ]
;
1 J* O, B3 E3 g+ S #c::
/ \, i& `: u/ W ?0 F' @5 F OpenCmdInCurrent()
# R7 ~. W* O7 k& `: A8 r return2 ` _- m# B$ ?
#IfWinActive
6 \$ w) M2 j- o2 f4 ^- O ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.8 L. ?6 @9 x, n3 _( t1 Q2 I
; Note: expecting to be run when the active window is Explorer.* F& P" }3 a2 ?" k( k* q Z! h
;
, ?& y9 _! h- b- I$ [# G OpenCmdInCurrent()! A: B& r6 t0 B+ \
{
k( k' c. D* n3 w- V& k ; This is required to get the full path of the file from the address bar
6 j* J! @% o: o1 P% g; b% y WinGetText, full_path, A
/ _+ U7 E# z/ A( x$ ]8 D ; Split on newline (`n)9 w$ h# w; c6 q- W
StringSplit, word_array, full_path, `n
E- B4 r- `3 f/ G, j3 M ; Take the first element from the array
( u! ?8 B3 p$ U6 y- r full_path = %word_array1%
. ]- i' s# f, i5 ^ ; strip to bare address( n5 r" Y4 E9 {" J- L
full_path := RegExReplace(full_path, “地址: “, “”)* x& U8 S8 _) j* o, r
; Just in case – remove all carriage returns (`r)
3 N4 U& r3 F: u' F StringReplace, full_path, full_path, `r, , all
: T0 S2 K2 E( _2 j IfInString full_path, \
& S6 I: @8 W4 E6 v {
+ \$ L; N' K4 w Run, cmd /K cd /D “%full_path%”0 F* D: X$ {7 z3 L4 I! K' _ W
}# D' Z9 P* h" B
else; \8 l9 h5 K* e* p g
{' g) _+ ]/ D% `4 P7 i
Run, cmd /K cd /D “C:\ ”. }+ H$ M" ?7 x7 |- C4 [
}
# A7 A3 @* G% w }
& u% l; w4 N1 e. N3 l8 ^ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。6 ~0 L7 L" o/ k% V7 X. w) i- k
这段小代码肯能有两个你需要修改的地方2 a1 A2 ?& ~, Q! C6 r1 {
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键6 ?' _9 h2 f( _7 Z) }# x: g
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
, E# `; f+ h# w) h3 P0 l% u |