此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。: w3 i3 L, C( s; ~3 U4 V
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。% R- E/ g' ]# Q; B( \+ Z7 t
方式一: b" f, u( a8 v) d
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,, i/ |) x, L# I& w& a! a6 z
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
) t, u9 l! [2 p/ c( C9 G ?5 P HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。, X0 X: i9 {4 A$ u
方式二:
. h3 J8 c C3 k1 {5 a 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:7 y& J" T: e5 y9 `6 r
SetTitleMatchMode RegEx
: e5 z" [; l: Y' m return
. z' y# L: g- B' o% l( s ; Stuff to do when Windows Explorer is open" j9 @0 Y7 i! N9 }& G; `/ Z% ^5 P
;9 @3 v$ b# [8 s, M' n X) |
#IfWinActive ahk_class ExploreWClass|CabinetWClass; a$ {0 M, j0 E* x& J- Z
; open ‘cmd’ in the current directory Z' o5 v9 S, ^* K+ l
;
! s; i* B+ f8 ^ #c::; Q! A! k4 g, A! N4 _, _
OpenCmdInCurrent()$ Y% v2 e* v0 s2 H$ {8 z. O& e
return! @$ z/ Y. o( v" }" j, m
#IfWinActive9 U) p' E) j6 {1 H4 a& h# s
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.( ^9 }: Y4 {1 T! P1 P
; Note: expecting to be run when the active window is Explorer.. S$ a0 y4 q; j, F! ^ d W. A7 _
;
4 I& V5 [/ X D5 y/ _) E: W k8 l OpenCmdInCurrent()3 r. H* l6 c% ^: x
{! C7 k+ S0 p3 [
; This is required to get the full path of the file from the address bar
. u% }- I# H8 X5 R+ V3 R WinGetText, full_path, A, }* K1 H2 B" ]' Z9 d/ \) c
; Split on newline (`n)6 t1 k \! }. J6 h2 r
StringSplit, word_array, full_path, `n
& o) R1 M) H8 d4 u1 t ; Take the first element from the array- M# N3 z, u% x
full_path = %word_array1%
! }# D1 ~/ {! t! s ; strip to bare address
* V# \" Q4 b* S3 r. x# s2 S. F full_path := RegExReplace(full_path, “地址: “, “”)
* `, }6 \) U/ ?4 h! c7 d! K ; Just in case – remove all carriage returns (`r)" O: c+ z0 [+ J* B: x0 H4 O
StringReplace, full_path, full_path, `r, , all9 K+ v ]4 u& A/ A
IfInString full_path, \
- P* i3 q8 A- w% _7 T. X7 D5 r; l0 Z {
' ^5 c- z3 E; F Run, cmd /K cd /D “%full_path%”
% `; X3 n* k- ~ }3 L; @/ y# @; C- _( n
else
# |; n5 u* @/ J& o) ` {
$ m. B/ ]7 l( ?" u* H. A- [ Run, cmd /K cd /D “C:\ ”
, L- b0 w d3 w' { }
% E8 n! Y" P8 ?7 X" m }, V I: K8 C" c L/ E5 J
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
5 a) s/ t7 @0 ~- _% r: @8 s5 \ 这段小代码肯能有两个你需要修改的地方8 _4 v# ~) b# r: l8 O6 E0 {" p
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
- ^( `* V$ G9 [3 n% O 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
( g' o$ |1 \6 q8 M7 P7 s# O4 H |