此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。. h4 K/ \. g! |
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
5 ^6 j# n5 Z# x( a 方式一:, r" V5 ?5 N3 N: a& r `
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
2 u, O' Y7 T) S- ] 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
2 y. j- x+ M* z0 J& L HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。, S! ^) d. L# m; g+ _5 d5 j. L
方式二:
+ e, i' U2 W% n v1 A 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:; |- R) X. y5 k8 @
SetTitleMatchMode RegEx
5 U/ z0 l u7 x return) k/ n7 y2 H. `" w2 _' M4 Z, m
; Stuff to do when Windows Explorer is open& ^: M) r$ E2 V* a' {' h+ ]- F
;; K4 _/ S7 ~0 {) C* H8 L5 B. n. I5 v
#IfWinActive ahk_class ExploreWClass|CabinetWClass
9 L% n- _6 t6 f6 o+ c% K ; open ‘cmd’ in the current directory
: Q {/ E8 Q0 j# {4 ~2 c' p ;. Q4 o7 N, ?2 B. A2 [1 q- ^1 M8 z | _
#c::1 j; Q6 {. v E# T( \9 X3 O
OpenCmdInCurrent()& h! ?1 c& l @& i
return1 {; l. U- N' o/ a" w2 J. F
#IfWinActive
7 x8 w( I: Y3 W# j$ ^$ j ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
' X" t0 p+ J. `0 g& Q( l1 H* c! P ; Note: expecting to be run when the active window is Explorer.
. o' ?) |+ m- \3 `: }1 I ;9 j$ B" _8 v: _: a/ ~2 b8 h( y; h
OpenCmdInCurrent()
; g' A, C* x3 m( `) U {
6 F9 H* B: E y0 x4 n ; This is required to get the full path of the file from the address bar3 p& t% i, m( Q x8 V. h7 L
WinGetText, full_path, A
/ B% N- i9 H' u& J p ; Split on newline (`n)' [/ u6 H/ K0 d3 J3 g
StringSplit, word_array, full_path, `n+ B! R+ q) C$ s3 M4 S3 _2 e" h
; Take the first element from the array
/ v$ h* B3 f4 f; s: w full_path = %word_array1%
7 N7 f5 M" @1 K7 B2 U6 n ; strip to bare address
3 l* \8 k& S" @ full_path := RegExReplace(full_path, “地址: “, “”)
0 t7 r/ h6 `* G K- D E5 _- g' e+ n ; Just in case – remove all carriage returns (`r)
7 a: ^, a! J2 G* z* l; {/ V: V9 p StringReplace, full_path, full_path, `r, , all$ ~& ]6 s3 t0 ^. e: G5 G
IfInString full_path, \0 g) K# C: v: v
{& \+ X F4 Y9 o( }- F9 s- O6 i
Run, cmd /K cd /D “%full_path%”# ^: C% z4 ^1 u' _! }; R
}
2 o1 |3 Y2 C; D3 k1 y: } else: m8 G+ o" S: k* Q+ K( S$ C
{
5 c" |) X8 @2 u$ o6 z/ t Run, cmd /K cd /D “C:\ ”' j4 T- S/ N: ?) a+ q, ^9 ^
}' k( z. y, g) c h$ u
}$ U% h9 S+ n N" ?3 b' h/ p5 @
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
- W7 j- ~ `1 }# c 这段小代码肯能有两个你需要修改的地方
t% K) `; B! U; h1 c4 M 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
2 p7 W4 p4 V" O) x: |) o3 n 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “+ b/ }" G- u3 A& }( H2 ]
|