此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。, }4 V1 }/ G$ N" o0 z8 n
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
$ g% B5 d9 H/ P! K 方式一:
* E" s( T# J7 ^# a& s& K0 e 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
* C2 J, R9 M; j5 X: C 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和% P; Q5 s# J. f! @# R A1 p" ]
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。/ P+ c- D" J" h8 n$ r! F2 S3 V
方式二:
8 _& h( d& ?' Z8 S) `2 `3 z 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:& d0 p; d' }, q
SetTitleMatchMode RegEx
: {3 j8 |" {! C- n7 i$ c- @ return# q9 C( V: |+ D; R4 w+ u4 m
; Stuff to do when Windows Explorer is open
* g/ _2 f' _# E3 L4 N ;
. ]( V* h( j/ u# Z% ?/ [ #IfWinActive ahk_class ExploreWClass|CabinetWClass
R; _, e1 k) a) _: }. i2 {5 B9 p ; open ‘cmd’ in the current directory: {+ o; S6 t- a9 L
;1 N0 M# ^8 l; j& D6 w7 ]
#c::
+ g' r. r8 J9 M8 a: I: @1 I OpenCmdInCurrent()8 l$ v, y# e. }5 n
return) z" c1 A; F5 @$ i5 Y5 v! x
#IfWinActive1 R- [% D9 } f
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.. f" k' W3 ^) z2 j
; Note: expecting to be run when the active window is Explorer.4 J8 ]5 w0 d+ f2 C& s7 b
;; p8 M& H: D( A+ L2 e/ q
OpenCmdInCurrent()% r4 z- \8 I! v6 l& U5 S3 Y0 V+ S
{
# r% n/ p# f+ n0 M; } ; This is required to get the full path of the file from the address bar# d6 c+ S( I& K V
WinGetText, full_path, A5 x4 b' D1 i7 p% x% V. y; p
; Split on newline (`n)- L$ n. I6 c2 w' p
StringSplit, word_array, full_path, `n
$ h4 v+ B: @! b+ h, U ; Take the first element from the array% X: M/ {, F9 i7 i- T: T
full_path = %word_array1%0 C; N* Z; |& U6 ]* m
; strip to bare address0 \ q+ B! R( W! O6 z
full_path := RegExReplace(full_path, “地址: “, “”)
5 j: g! T% L0 C6 y$ m ; Just in case – remove all carriage returns (`r)! k. l7 b" w9 {" {1 Z
StringReplace, full_path, full_path, `r, , all% ~% H5 \5 n7 S" ~
IfInString full_path, \$ t& w2 \% j- K A- s
{9 ]/ o$ B% r$ u" B" Y
Run, cmd /K cd /D “%full_path%”
* W8 z. ~% K7 U h8 g }1 p; b& Y& C/ @
else! ?1 \; a2 W# T( {1 L
{
3 v) M) c8 D! f0 q- v1 J. q Run, cmd /K cd /D “C:\ ”
) ~- h7 r& b- L! Z+ E5 s0 K }
* \- Q& K( J F7 y6 J3 b, @, D }
) S! C' v9 w) r! \: N: Q ` 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。( f$ ^4 F3 z: J: y" E, u9 O. R6 S
这段小代码肯能有两个你需要修改的地方3 k, I' ^/ q8 h6 Z2 d
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
5 q1 y9 d- H6 R$ ^% {2 @6 G: i 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
3 W% f! I2 V5 E) C# B3 I1 q3 x# S+ ^ |