此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
9 q3 Y t7 w2 x3 X# I! o) s 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
* r1 X# A2 v `$ r1 R) v/ G) s 方式一: C1 I- b6 X" ~) S$ p
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,: J4 k& `' B4 J, [4 ^4 k
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
( b$ S. P3 N& t5 |; L! j, i HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。( Y* k, O1 m& K5 q; ?% D
方式二:
4 U2 \/ P) [; [6 x* t+ U! G 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
2 e6 i) {8 b; P5 C1 U, f% C3 j SetTitleMatchMode RegEx0 K: t# \' V% T9 x" Y2 U( x
return$ J! A& m0 ^- Y+ y/ E
; Stuff to do when Windows Explorer is open5 k, n! O# z8 ?% ^5 A) C
;; } O7 P g Q" ?
#IfWinActive ahk_class ExploreWClass|CabinetWClass! i3 ?$ Y+ n f4 w. A) F/ F
; open ‘cmd’ in the current directory
% |% H3 \% {. t" F ;9 e% V, i# z1 S) e) ^7 v
#c::
- ^8 e; K5 x, r9 Y% X7 [' p OpenCmdInCurrent()# F. U7 A2 b3 z
return% I3 r9 s) x( {9 y& B
#IfWinActive9 U7 r. T3 `! C) e& g. }$ o
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
/ B5 m+ p9 ?4 i! P ; Note: expecting to be run when the active window is Explorer.7 B( ~6 S/ ^% {. z* i
;! Z1 @1 R1 w4 z4 d* z2 j1 z: S
OpenCmdInCurrent(); \) w3 w4 D1 n: M
{
1 H D4 Z6 x ^$ s ; This is required to get the full path of the file from the address bar
* }6 N* {9 a( Q& {; { WinGetText, full_path, A& L& K1 s+ g. b% v. Z5 |2 s
; Split on newline (`n)8 ^0 W) P6 v& c% D
StringSplit, word_array, full_path, `n% x( @3 j k8 `
; Take the first element from the array
; F0 v9 S: v' t" O" w4 Y3 b full_path = %word_array1%5 L) Y. O% p8 P* v: c" K4 z
; strip to bare address E! q2 q3 ^# m! L/ C: y4 _! c
full_path := RegExReplace(full_path, “地址: “, “”)$ Y9 R1 d7 s, r I
; Just in case – remove all carriage returns (`r)
% Y+ y+ _9 d( N+ g* Q9 I: q StringReplace, full_path, full_path, `r, , all
$ H8 E7 ~* q) S+ ^0 N. | IfInString full_path, \
3 S7 Y+ c$ O3 y# U {
* p. _- i( K- w: \6 D9 g Run, cmd /K cd /D “%full_path%”
6 f' Y k/ }9 ]3 J3 d$ d; @ }/ O q" h, ?) Y" l& o
else) @' n3 i- p" q% l4 o) w: \* \
{, E4 M- W. w% D8 O
Run, cmd /K cd /D “C:\ ”8 l9 @& w w8 {" z; L4 r8 a) U) i7 {
}
: [& E9 w' D. T# r% s2 D }
6 N. ]$ f# e1 C' X F 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
0 G. e4 r' [* B# G( S 这段小代码肯能有两个你需要修改的地方
( D- E3 s/ H3 |, O- { 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
3 U! q- J9 r4 m: X 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “1 i, m1 j' a& I$ o
|