此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
" o6 _; p' |0 j4 k: q1 |/ N1 D* q( N 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。& F# O2 [' `0 n* G- e
方式一:7 q8 z6 a7 J* v c3 X; S
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表, _: q3 a( v/ j3 W9 f) a
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
4 @: Z$ U) A" K9 ?8 n% C HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。7 a+ t. Y7 N8 X; D% A
方式二:
% O+ Q5 H I7 J5 G9 L9 L 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:; l% {) ~+ R$ V4 |$ J
SetTitleMatchMode RegEx
: y, u/ u# i1 p( q" W' y+ F return
/ z2 c! @0 H( [# r/ ~ ; Stuff to do when Windows Explorer is open
5 m4 G& g' U% T& i ;6 A3 T3 N. @5 X7 G
#IfWinActive ahk_class ExploreWClass|CabinetWClass4 X/ T0 ]6 y1 k, `* B. g4 t
; open ‘cmd’ in the current directory
, j- }6 x4 F5 \/ [2 u ;
3 g2 P c) n0 H% [) t2 a' q( T #c::
! E! l* \% o6 W) Y; ? OpenCmdInCurrent()
' J- R- K; o0 ?3 @ return
3 t: L$ V& x1 R5 I! ~ #IfWinActive4 S! B# H3 R& p& u' C. g1 n3 e1 ^0 _# d
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
3 ^ x) V/ I3 h2 z ; Note: expecting to be run when the active window is Explorer.
. v! g+ g Y$ q# Q) I0 b e& N ; D: j z) o2 ~3 B9 S. M/ V
OpenCmdInCurrent()
8 w% {4 p% Q/ H* T {
4 t$ q. u; _8 D3 r) `, c# z ; This is required to get the full path of the file from the address bar
! A, g) }2 k" ~, T! [; e WinGetText, full_path, A" M- i5 i4 A& K- I; P, r( `
; Split on newline (`n)
: X( {# _+ e" Q! D5 [, H StringSplit, word_array, full_path, `n
- ^4 S/ v" ?) S7 {& P2 f" g ; Take the first element from the array
' N% H* \, t% ? full_path = %word_array1%# I& j6 ]% Q' W+ ]4 R# ^
; strip to bare address
; ?, n$ D- ~( l- U full_path := RegExReplace(full_path, “地址: “, “”)0 s4 U6 x' G" D# g8 \
; Just in case – remove all carriage returns (`r). F; l; t/ ]: w2 A; |
StringReplace, full_path, full_path, `r, , all
/ ^1 |. D$ @4 L6 M5 `. A# F o IfInString full_path, \
- K6 l; m7 D3 L6 u( g# H0 P {0 S' d$ m; z7 W6 i6 \" }" g
Run, cmd /K cd /D “%full_path%”; X) {5 h' Y6 B2 M: ]
}
9 I( \2 W" F8 Z! O5 K6 a0 V- C' k else
/ M2 }" H) s$ @8 B9 k {$ r; J1 H' v$ c" z
Run, cmd /K cd /D “C:\ ”
0 j4 a) _1 |/ ?3 o+ K }
( N: J+ z: e* r9 z }
- C$ @" f- c& e3 L6 y 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。9 J- M8 T- a4 `, ~6 b
这段小代码肯能有两个你需要修改的地方- N6 H9 G/ C9 X J
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键) L6 b9 `3 O/ g! L
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “4 Q1 \4 Z# Z- y( P# _8 Z. {- q
|