此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。, G8 j* Q) e3 o* C$ |
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。. N+ F" E& ]% M& g- y# |9 ^
方式一:
u& w' [2 {; b- a ` 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
% u) |* C( H" [% Q u2 ? 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
1 O# Z( L1 I. e HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
7 o6 H) O5 o) R0 s, Y 方式二:
) o$ m8 D, S# m# g( K 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:& U) g4 L! j# i2 q: b' s
SetTitleMatchMode RegEx
2 c2 T( f# k; x) s8 _: e2 j( S, p& A return
S8 @( R$ E: V3 c3 b. @+ v ; Stuff to do when Windows Explorer is open) s, p2 X0 [$ X4 w8 S0 P
; a* [6 l" b/ L
#IfWinActive ahk_class ExploreWClass|CabinetWClass/ l' v) U! X3 ?+ N0 p g
; open ‘cmd’ in the current directory( p! g& q6 a8 {+ V P
;
: q' p9 Y5 _" Q2 M #c::: O6 g' G" X6 f+ u
OpenCmdInCurrent()" N4 {7 K# w* @2 _8 G: G
return
; o* W# _( ]# | #IfWinActive
% x" d: b& M$ C ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.) a' ]0 \# o) l7 p0 @. ~
; Note: expecting to be run when the active window is Explorer.
% L! H$ O/ [ L# u. v8 @( Q( J$ i ;0 V9 H" c8 |; z* I; n
OpenCmdInCurrent(). \- J4 ]2 Q4 n P7 l% Y& Y1 s
{
* O7 f+ k# P1 X( {7 x8 z2 b$ m ; This is required to get the full path of the file from the address bar( x: n+ T" b: W1 A" c
WinGetText, full_path, A
' X$ m% c1 j- s ; Split on newline (`n)
$ |, f# f6 ]) N! g8 n! @& O7 _( k StringSplit, word_array, full_path, `n
$ ?& w7 @) C* \7 O1 A ; Take the first element from the array
3 \( I D% s1 j) J& O/ K4 B% c$ d9 u full_path = %word_array1%
6 K3 }, C; A9 @. B. u6 t% \ d ; strip to bare address6 g, q2 F! J8 o! @ c( o J+ Q
full_path := RegExReplace(full_path, “地址: “, “”)) D9 I% N/ N$ { o
; Just in case – remove all carriage returns (`r)
: d( t1 b( w/ [" i! O U5 v0 o StringReplace, full_path, full_path, `r, , all
5 a, U! q0 S0 X$ ?# I IfInString full_path, \2 ?5 T" T( W5 m, J+ V! t
{
0 E; A& z2 u1 X Run, cmd /K cd /D “%full_path%”4 y: Q; K: I: u/ C- O4 H
}
- r7 [$ ^4 c" s7 L! H) f; `3 F else; f+ }: _4 F. I# z% b X1 T3 T% [# q
{
2 I9 G2 X7 n! O- X6 Z( ^ Run, cmd /K cd /D “C:\ ”, f. I- O) j S8 L1 g @
}
$ x% L1 ~! }) r5 O. P; c/ Q8 a }. N8 X4 N; [% J
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。5 m6 r" J* [- T1 G+ i
这段小代码肯能有两个你需要修改的地方
& {4 L5 e U, e, F' W 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
$ Z" J6 c- \" ^8 [) i- { 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “$ W* ~! i/ t7 E9 M& d3 R1 E
|