此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
% l; ]+ W& Z+ ]' A6 n% B 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。$ W. q1 R: {% \$ \7 Q
方式一:' [9 a1 b" @0 B$ r) E
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表, X$ W$ |9 b/ P9 e
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和! x, g }4 _1 [ X! ~. q: k
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
* r7 F# x- t! p6 n$ u& t 方式二:
2 F" t7 V g3 ^6 v5 i 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
/ G1 [; j- I$ l4 `3 F. m SetTitleMatchMode RegEx
R* r8 V/ S( ]& a5 _1 F+ E return- n6 C; W* N6 X2 @( O( w5 F( d
; Stuff to do when Windows Explorer is open$ ?2 G T) V, M3 K, [5 x
;3 s' l8 K) P- O- t* O9 B! Y
#IfWinActive ahk_class ExploreWClass|CabinetWClass. h9 ?, r4 i1 x3 D, r4 o# t
; open ‘cmd’ in the current directory
. T3 H4 p2 u8 O- u4 t ;
$ l2 z5 k' @+ ~/ O% B #c::, B; J6 X) o5 n7 D8 N
OpenCmdInCurrent()
) q) D+ @. C/ M0 G+ V return8 j4 }* D6 Y8 m5 K: b) R* d% Z
#IfWinActive% X2 |7 C5 l$ T! s+ H5 ?* o0 P
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.) G( {. g5 O, M0 P
; Note: expecting to be run when the active window is Explorer.
; x- A5 i4 C9 w8 l ;& O* P7 N1 o: f: ^( }
OpenCmdInCurrent()
+ t. o$ E5 _1 o& {( I9 T {7 |3 a8 s% m$ Z2 ~' B. k+ o
; This is required to get the full path of the file from the address bar
- @2 y: x# Q4 Y3 u) ^( k WinGetText, full_path, A
( l4 H# {/ E( U. ?& o: i w! ? ; Split on newline (`n)
" A+ x2 [8 A+ R1 X" J% l* g StringSplit, word_array, full_path, `n
- j2 y( C3 S- w: g5 B0 P N ; Take the first element from the array
. C8 B: @0 m2 U% s full_path = %word_array1%
6 v2 o2 q$ m1 [ ; strip to bare address" \3 D6 e! t& O
full_path := RegExReplace(full_path, “地址: “, “”)
0 e+ t' y. l* ?- F" F: i' k ; Just in case – remove all carriage returns (`r)- w- B+ B; |: T. ]) S& s# P, b: u
StringReplace, full_path, full_path, `r, , all( P$ b) K/ H7 u3 ?8 Y# F- F! {
IfInString full_path, \8 Z, b2 B* U' A; t
{1 p) R4 b: c7 n6 K
Run, cmd /K cd /D “%full_path%”# B3 {4 K- T+ E# P' B
}
9 w/ e0 p- T5 ^ ^3 x% n! l else+ w$ K8 c6 |+ X" s- y6 X* B' N) [
{! V$ B! V4 \! l# Y! j O4 B/ V: d+ u
Run, cmd /K cd /D “C:\ ”/ g6 f! @: |! x& }( j& t
}1 S1 ?( `$ N, c
}3 m9 t: w7 e% T+ ~
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
: r. ~+ h& E5 h. [4 Z6 y 这段小代码肯能有两个你需要修改的地方$ I# S1 S+ m! A) @/ h
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键( c9 ^7 c$ l7 ?! x6 ^
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “9 t- u; t1 ~# c* c. U2 x( r
|