此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。! C* D, h6 C9 p- x6 E/ |4 [, Z
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
, b B: W+ W% w {! r. t" O 方式一:
: w& M9 d% T& ^( A 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
8 |% q* O! c+ g4 {7 s 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和6 b- o6 `* S2 z1 h6 \+ U5 S
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。0 v3 U o: s3 l# @6 n3 j2 F) }
方式二:, {8 k$ x d% d+ i3 R' D
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下: b. F1 o8 q3 Z) J
SetTitleMatchMode RegEx
2 l; h9 `: e$ f return6 }; M' Y/ x0 A* X
; Stuff to do when Windows Explorer is open' {8 J) x& b$ K
;
. n; z: l, C! O* [- [) M( u- \ #IfWinActive ahk_class ExploreWClass|CabinetWClass# x; F* } x+ Q& e3 U) x
; open ‘cmd’ in the current directory
& Q2 R! w$ \9 M9 T ;! d1 m( v$ M+ E* P
#c::
b7 F+ u: O5 s% M, h- F OpenCmdInCurrent(): b$ r, A; C$ @6 z! t, u0 Q
return
4 M2 ~! R* j- ?) F( B #IfWinActive8 [$ n+ Q& l8 O6 H5 u
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
; I+ y( ]# Q) I, u) Z4 _, T* f ; Note: expecting to be run when the active window is Explorer.: D% T, Y0 H, p2 }8 H
; t2 d$ a. B& O- Q
OpenCmdInCurrent()
8 A, `/ G- P0 @+ Q8 } {# y/ \; |' y4 D; T7 I% M8 h& t
; This is required to get the full path of the file from the address bar
8 [3 `, r5 |" ~9 ~1 X8 l6 F7 @ WinGetText, full_path, A
3 ]# o* Y3 [0 V' L* F' {5 Q ; Split on newline (`n)' ^$ ~; K {& e3 T+ ^5 s3 |' |
StringSplit, word_array, full_path, `n
# P6 Y6 w$ l* N: i8 n ; Take the first element from the array
) ~+ S* @* _: \0 O' n1 R1 e: M full_path = %word_array1%! ~. X0 @& t' `: G
; strip to bare address
7 Y1 f% E( E+ ?0 O, j- L full_path := RegExReplace(full_path, “地址: “, “”)
2 h0 p7 Z1 I- G& z! G ; Just in case – remove all carriage returns (`r)
C4 G( U) O) f/ X# G5 G' H8 k StringReplace, full_path, full_path, `r, , all$ |3 r1 U5 I9 R8 A- U& b% [
IfInString full_path, \
% g1 D- B1 L1 v! ? {% Z9 c1 L7 q$ a# R7 Z V- g
Run, cmd /K cd /D “%full_path%”
L7 G5 S: u; l; R* ?; y }) O4 O9 Z6 m5 q
else7 X& d# {7 i" Y4 [4 h& k3 i- E
{
: Q2 f6 j3 l3 Z6 Z& A1 u; j7 | Run, cmd /K cd /D “C:\ ”
1 c! [' R" y. A# C8 n/ G, S; R }4 O5 w( I! h$ }: v8 T3 ^
}) D5 \8 P* H' R3 I5 P
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。! I' o; A! X- d6 y+ C7 X
这段小代码肯能有两个你需要修改的地方
! o: F F3 g" q `# C6 U, b. c 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
( c9 k5 @! i0 Y7 O0 Q0 \% L 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “0 |) l# N; V! t* R" m P
|