此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
) \2 X8 T7 ~& w1 ^4 E* q% v* c5 s 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。, [" Z3 V6 D, u0 _/ R% Y
方式一:
- f; S8 z$ z( ` 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
% [. ]& q, t4 I1 {( R. X 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和; n1 ^: e) Z/ U+ A+ r4 [" B% T/ ^
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。. X" i# x, ^" K1 v6 [
方式二:0 S% Z9 L9 M8 Q) @' e; S
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:) F) h1 W" p2 F; @0 Y; { m! g
SetTitleMatchMode RegEx
: v: |( F8 p: A* K N4 e: S return
5 t3 s( z+ A$ H/ D% q ; Stuff to do when Windows Explorer is open
# f8 \7 f; u/ [1 I/ L ;. \8 \, e, Q8 L% P; T+ T( C- `
#IfWinActive ahk_class ExploreWClass|CabinetWClass# n3 d t+ Q9 n8 m& Z
; open ‘cmd’ in the current directory
1 ]2 B( m/ ^0 Y1 c3 ^ ;; Z, P; r; _0 _7 l: x3 f
#c::% q- G6 \7 J3 ], _5 V8 z! k4 v1 M
OpenCmdInCurrent()
4 L, I G. a5 b' A3 Z* k2 R return
% d/ `* h4 O, u: [. S% @3 i: r* J2 i #IfWinActive
' I( {- e, ?6 c- `; F, ] ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
3 b9 a4 ]% q7 d1 [, x0 {0 S+ ^ ; Note: expecting to be run when the active window is Explorer.
- @! s" b& s- S ;. w1 Y: x; ?) |( [
OpenCmdInCurrent()
' ]' v7 X& S' P: C* Y+ `' b {6 k4 ~& [* A9 o9 ~
; This is required to get the full path of the file from the address bar0 ~2 B# v2 P6 J# g5 L" `
WinGetText, full_path, A
6 m' U( b- `$ ?! s ; Split on newline (`n)
: F6 i1 K7 ~! ]8 q StringSplit, word_array, full_path, `n
- A, m" Z2 d$ M' I* L" t# V! {6 t ; Take the first element from the array" D: [+ D" r: @4 }7 O& k; X
full_path = %word_array1%
- l2 I4 _* s4 M+ X, W( | ; strip to bare address( y( C, t& {% @1 e9 X6 }% i
full_path := RegExReplace(full_path, “地址: “, “”)& |2 l8 ^+ ] l! e
; Just in case – remove all carriage returns (`r)
+ a+ e5 ~3 S) c3 \% d StringReplace, full_path, full_path, `r, , all% x- S' k4 S) Y5 s: B
IfInString full_path, \& _* y# @5 @! o2 ~$ K
{# \# W9 G- J+ H8 U+ G( i6 y
Run, cmd /K cd /D “%full_path%”
; U- j4 J1 O! p) k& n }5 o" y4 v/ G; \' ?7 {
else
1 N/ i& a4 F! d9 X! Z3 _5 j {
/ F: r( Y. ]/ `' S: F0 l6 j Run, cmd /K cd /D “C:\ ”
9 q' n" ~5 O2 Q( o; a5 m8 U }( j8 |/ ~$ f2 z) I; f% O" Q& r: T
}: [0 s2 H5 Q) b F" D, F7 x
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
- J i( m8 s, r 这段小代码肯能有两个你需要修改的地方
5 G. x0 Y! z+ E9 a5 u 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键2 D* B5 C# A% V3 L" ?
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
* t$ e- [1 Y5 I6 C: [ |