此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
+ Q! W$ u7 `, x- r4 y! }- ?. v 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。& f- ?8 V- }$ p9 D u. r' g/ W
方式一:
0 A' {$ H% R; Z1 M+ @ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
z1 P- L! \/ G/ l' J 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
9 G" _- @' w( i2 C: a HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
! \8 c3 [! m) i) a9 E% O 方式二:5 e( O3 F" H2 X0 y1 q
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下: `, D- P" x5 K. a9 J
SetTitleMatchMode RegEx {7 S( ~4 w$ R$ p x' z5 r7 f
return9 q: d; N( L! f) A8 x8 w
; Stuff to do when Windows Explorer is open
# t; G! H; o- C, ^! b7 c3 b8 C ;4 F4 M# W8 U2 k; G6 m4 F2 F- h7 U% }& w
#IfWinActive ahk_class ExploreWClass|CabinetWClass& x1 `/ k6 C% }$ y; q: n# |
; open ‘cmd’ in the current directory/ a% z( a2 R7 j5 S$ n
;
) D" }; z; t( | P* o& Y ~, {' ^) K #c::* y0 @- j% V; p4 g3 v
OpenCmdInCurrent()
2 k/ {. d9 S4 C+ p! g+ C return& `2 g3 a I6 u# F6 c, d; a: f
#IfWinActive! S0 U# [0 C2 x0 X' W
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.5 F, x5 N. K* K9 X; @
; Note: expecting to be run when the active window is Explorer.
/ `( u/ `7 g; x: f7 T ;
+ C( B4 j- f2 f OpenCmdInCurrent(). J- @% B# f& X# J" R
{* V* H3 D0 K) ?3 f- N1 W6 h$ p
; This is required to get the full path of the file from the address bar
5 k) E9 y0 a2 R! ] WinGetText, full_path, A( q8 n9 _! u u: S! K6 ]+ M
; Split on newline (`n)8 R4 K4 m* ]. z0 |0 S( c
StringSplit, word_array, full_path, `n
8 k& `9 j- {6 S! N l ^1 m ; Take the first element from the array
: d' e( R m1 a full_path = %word_array1%" y: A3 D1 _7 T" P
; strip to bare address2 I8 V6 T- l2 l! t4 n! U
full_path := RegExReplace(full_path, “地址: “, “”)+ W. B+ K! w, p+ o9 ^) L! G/ f# J
; Just in case – remove all carriage returns (`r)
* H8 I; f# v9 v+ @7 | StringReplace, full_path, full_path, `r, , all
5 E2 |$ I7 B" M7 ~5 I. ^& M IfInString full_path, \7 V8 D) T/ D0 y
{
3 M# C8 f/ r/ i Run, cmd /K cd /D “%full_path%”! D: _4 D: e0 M$ A8 c: ^' c
}. l$ G' |# i6 k, `* Z
else
) E. \, ^0 Y0 K8 c; }' `4 t {
5 o0 W3 K3 `8 y# T; E2 b- ` Run, cmd /K cd /D “C:\ ”$ V$ j4 M$ l2 j8 s( C& R
}7 M& m. t/ [ F
}( O! `% T' E. q" @% ]: x
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
. g: l9 ~) k0 ? 这段小代码肯能有两个你需要修改的地方
- a: [; X: ]; N5 p3 T r1 v; q. r 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
9 ?+ K& r; Z& t4 |0 W* G% I* \& ] 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “$ M. g& C. i4 c! }$ n% z+ W! ?
|