此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。8 `1 }; J( u5 [2 t3 Q) {
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。3 A J% B& d9 b) {. D3 z# K
方式一:
! T; [, t; O5 w) [$ A7 ~% N L( o4 V 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,2 o1 W+ q" }9 A& X/ d
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和3 E1 R9 l; {- _9 W* W4 ?
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。. f* y' d3 w& ?0 D
方式二:8 ?' N# h: k$ [8 _2 y
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:: P- t$ A' D" w& E- Y1 N* s2 n$ R6 W
SetTitleMatchMode RegEx
1 @/ H+ ?: [; G7 d, r U1 M* F return/ k P+ ?/ s @3 V4 D; e1 c
; Stuff to do when Windows Explorer is open# ^! d( b/ W6 E# T
;$ t6 V' m0 f0 l+ W, F. ?4 X
#IfWinActive ahk_class ExploreWClass|CabinetWClass
7 `1 ~8 k9 T2 p3 ^' m2 g ; open ‘cmd’ in the current directory
& q/ x& Y1 d$ Z+ }" F ;. `+ [ X( v5 t) c7 `
#c::1 `& e1 j, T# v
OpenCmdInCurrent()
' r3 l, y2 g( A; N/ A- P/ B$ L4 m return0 z* x6 [' u9 K$ k- [' |
#IfWinActive8 m; l v& w& W
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.8 B2 a6 W4 W2 D* ?' R- Q+ T& s9 ~
; Note: expecting to be run when the active window is Explorer.& n6 T8 @0 Q' [- A% O
;# U) T8 M4 g/ I9 K. A# n
OpenCmdInCurrent()
" w, D- h' }+ _7 z4 H3 f( s {
]' F! m: z- N4 i& @; D4 P4 }3 T+ a ; This is required to get the full path of the file from the address bar0 k! F( C/ F3 h( D% T6 c2 n6 g. F
WinGetText, full_path, A# H2 |& b t4 o6 V3 O
; Split on newline (`n)- I# ?1 G- _3 _! d
StringSplit, word_array, full_path, `n
* ]% J5 I% r: {2 h ; Take the first element from the array
9 c3 G- z2 p" a; Y1 K [ full_path = %word_array1%3 n0 j' c, D# ]: | m
; strip to bare address
, v" N$ q9 p& D- I9 {( r5 ^ full_path := RegExReplace(full_path, “地址: “, “”)1 ^/ i5 s @& Q# w' K
; Just in case – remove all carriage returns (`r)
2 q- z, W, v& s# _5 V2 B; ~& c" B StringReplace, full_path, full_path, `r, , all
6 E6 Y9 h3 u1 f: I6 t. D IfInString full_path, \
6 v z7 l2 X1 N/ {7 j- h& n {
: f! T }! N5 `* Q( H! W Run, cmd /K cd /D “%full_path%”
, M* l3 B% i8 N! F7 g9 v# z: { }
1 N' V# j: U2 W: D" I else) t B. s+ v8 B* ]: ~4 K) O2 J t$ j
{
" G3 f ?! p9 r9 Q Run, cmd /K cd /D “C:\ ”
$ \" i( c* ~# k9 ?5 d( _6 V. B! T }
* b; Z; D5 Q$ \) R3 g0 s }* D7 L* i* d) v/ m8 K; d
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。 }9 g% v! E1 R7 `& o( b1 G! G/ V
这段小代码肯能有两个你需要修改的地方& k5 f) D7 V- X: d0 Z
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
( u9 [9 n( U# p5 E+ Q* G 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “) L0 G$ |$ Y* A/ E$ Z4 I. k, w, B- n
|