此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。; K$ A1 _' r& K' v" m/ p. b: r, ^
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
9 V0 O3 F* F7 H$ F! w; K9 W 方式一:5 s# M1 V# q6 p9 ^- F7 u7 Z
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,0 I0 x5 o) P0 Z' [
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和/ f& i& a. ^1 u: |# P
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。4 a1 [. c2 S) l. L- a
方式二:
- [1 Y! ^7 E) Q( V6 {9 [4 f 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:( L3 t7 v+ r4 {- Y: U8 s
SetTitleMatchMode RegEx
1 C* |9 l0 r6 N2 s return
) U4 o6 v& J0 f+ h ; Stuff to do when Windows Explorer is open
, A! _" @6 v1 U4 P+ N* n ;& X+ h6 j1 G' D: X* E) h2 x% z8 o
#IfWinActive ahk_class ExploreWClass|CabinetWClass3 I7 U) ?. \% N9 z
; open ‘cmd’ in the current directory8 k- V1 x/ p" S/ E# H
;
' f3 U. d: ^' n- l: p* ? #c::
3 g& ` t! `! h+ v" q1 g OpenCmdInCurrent()+ \! x: }! d7 y0 C9 H9 j
return
; S$ l5 \. A0 e& F2 h1 E; e #IfWinActive
1 F- w; x4 C8 m5 F7 `% v: C8 X9 Z/ } ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.- Z8 D9 k& @) U- ^. |0 ?5 E1 n
; Note: expecting to be run when the active window is Explorer.
" o6 H4 I# O, b! G7 Y9 H8 H) }; H% B ;
/ |' J# { W& m4 {: z2 r- s9 e OpenCmdInCurrent()5 B4 O9 ~' u2 v
{
4 P! w, l$ |3 u7 y2 s ; This is required to get the full path of the file from the address bar
! I. d1 ^- m# ]3 h8 b' ~2 M WinGetText, full_path, A# v5 x5 u7 v q: `. G
; Split on newline (`n)
& z2 t9 B( T; q7 ^9 \ StringSplit, word_array, full_path, `n6 K8 D. J% n s: Q3 p# U% D; c
; Take the first element from the array
! A, `6 ?* u% M# G8 F0 P$ D full_path = %word_array1%
7 N9 {/ Z6 i" a* o ; strip to bare address1 v8 |& s6 P5 o# n0 S- @$ m9 e' `
full_path := RegExReplace(full_path, “地址: “, “”)) w! u# j; d3 e4 `# d
; Just in case – remove all carriage returns (`r)6 W2 N% g0 ]- T. V; l1 L$ d
StringReplace, full_path, full_path, `r, , all! b* w' o# B2 s. n
IfInString full_path, \
% R# G3 Q; A) d {
( ]0 \/ ^1 R5 t2 I) ^0 `' N( L) y Run, cmd /K cd /D “%full_path%”$ ?3 I2 Q" V* H* r+ g
}
. |9 i4 }6 u4 R# T2 p else
( f6 T& ]* i7 n, n% x* H4 R {
3 r0 w+ u0 i9 W" B! d* N Run, cmd /K cd /D “C:\ ”! A. v, J# b6 Q" o) K, v
}
. U5 |' m1 |* U1 @) o }
- o3 b( a7 s/ m: b% y4 I 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。5 w/ \0 t) V! `) u5 H( ?
这段小代码肯能有两个你需要修改的地方
$ c; B4 B* @$ `6 w 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
; X! w4 [) z6 J: ~# o9 b 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “% c: m2 u/ Y) C1 v# K) ^* W
|