此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。" X6 {8 U/ b2 ]: p. m. I& G
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
- s; y1 r4 D- }/ [( L 方式一:
+ }2 Y1 {8 A5 s4 t6 ` 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,; b5 w8 D) W8 R7 x4 k0 d' k
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和2 ?! X I8 R( M/ L! ^- l
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
7 k4 {8 |/ q! H/ W) p+ p 方式二: j, I/ O( _1 r% i
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
9 H e5 X4 ?8 {$ } SetTitleMatchMode RegEx+ Z0 P+ |$ h3 x6 F3 {
return) p' a0 v, E$ L
; Stuff to do when Windows Explorer is open
) G3 ^" t7 g5 E9 A+ ~) p. k ;
5 S2 w& X v7 ], y* p #IfWinActive ahk_class ExploreWClass|CabinetWClass
- t" C! J8 n1 X1 v/ `6 o0 I ; open ‘cmd’ in the current directory# L# V0 n4 ?6 o, ]( ?8 n
;
$ r" G! h- K8 C* w" f4 Y j2 } #c::
& K9 i0 ]( n. a9 ] OpenCmdInCurrent()7 S# e8 e( \4 P' Y2 r/ }2 d1 w
return+ c |5 q0 h- V
#IfWinActive
% d% X d" {6 e3 m+ z ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
# O( _! J0 ~( J& a ; Note: expecting to be run when the active window is Explorer.
* z: h, p2 a/ P& u* X ;
; _5 e4 V$ Q2 `) f( f, u R OpenCmdInCurrent()- H" d2 _! {' a+ A5 ] E. \
{
( R. g5 d- V9 w; T9 w7 k ; This is required to get the full path of the file from the address bar
! }; p2 V+ |0 c9 {. M/ h1 c WinGetText, full_path, A- e8 e' r( |. e" [( i
; Split on newline (`n)
1 d, Y1 _* _! }$ N: X/ g StringSplit, word_array, full_path, `n! f$ b4 e1 d0 F) u
; Take the first element from the array
9 B+ L& k8 w* | n8 j full_path = %word_array1%
1 ?$ |4 P/ K7 a ; strip to bare address
0 Q, B, B3 p- s! {; J! ^( k full_path := RegExReplace(full_path, “地址: “, “”)/ V+ H: i+ t( G8 n9 w6 D
; Just in case – remove all carriage returns (`r)
9 j0 J1 H# y6 e2 |" q- A StringReplace, full_path, full_path, `r, , all
" p) O8 B) b: |$ r" c8 w% x IfInString full_path, \
1 j6 [1 ^5 r# i; F4 z/ @ {
8 e6 z3 x! p5 t$ \6 o Run, cmd /K cd /D “%full_path%”5 B* {6 ]6 n# D+ V" m
}9 s, {8 \; f) L r, o" d8 |7 c% R
else3 S" ], W7 Y; g, t
{
# x$ t6 |+ v- Y+ W Run, cmd /K cd /D “C:\ ”
* ?! ?2 V$ I' k6 E) a3 F& m9 V }( E2 }4 Q5 L' j0 t& M+ v5 M
}
: y8 z& \, {9 m 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
# ?+ A" W; h" G+ e L* V) N 这段小代码肯能有两个你需要修改的地方3 I5 o- O$ N& Q6 p. o$ d3 t* s
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
/ n* p; n1 u3 z! l 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “! e* W- M6 e$ g
|