此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
7 M) ?0 I* Y, s' ?2 g! c* n 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。& p+ X! J0 W3 i7 \! L2 C @
方式一:; b4 r8 o- p' r. _
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
7 P# y p* o X# I ] 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和* C& @+ N8 k% d; i6 {7 M
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
$ m$ K4 p2 N7 w j3 C5 O! L l0 f0 A! X 方式二:7 A. E/ g# E" D( @
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:9 ?& M' @8 K1 e2 k f1 Y& y, B
SetTitleMatchMode RegEx
* ^6 O V, l* n( U( [4 w; u return
. h8 `" j. T& a4 L ; Stuff to do when Windows Explorer is open
+ M; x% A6 Z$ ]4 V9 T! X) A ;
1 k" c* {8 l$ Q2 W& ]4 ^ #IfWinActive ahk_class ExploreWClass|CabinetWClass
8 f) Y/ C# F& H) l/ Y8 o" L0 m ; open ‘cmd’ in the current directory5 C, [; [$ m: B( M; g6 j, k% ~
;. Q( S' E3 S' B! g+ ~2 v, |* ]
#c:: _) D$ k6 A8 ]1 v- M
OpenCmdInCurrent()
7 w/ t) T- ?+ R/ x2 M9 U return
: F" P4 _' r+ _8 x2 V" u4 L #IfWinActive2 L: K, M- d; F2 X
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.9 ~( I V" G1 @* l. N
; Note: expecting to be run when the active window is Explorer.
/ E9 g d* c- ?* ~5 P ;4 y' C, t8 [. K, ^: G, {
OpenCmdInCurrent()
4 H5 f) l" j# R; [ {6 n; \, R) x" \4 f5 |/ z
; This is required to get the full path of the file from the address bar0 y& ~+ W4 X3 J& ^4 n
WinGetText, full_path, A! [: X+ P6 H2 o& ^
; Split on newline (`n)1 O! d2 b! M2 _" m* x
StringSplit, word_array, full_path, `n
~7 n# t. Z. j3 t1 h% }: X) c ; Take the first element from the array
5 t7 ^) ?7 ~, w full_path = %word_array1%
% L# K4 [) Q/ b) @1 H7 K0 K) f" r ; strip to bare address5 C- G3 ^9 L# |5 z: z7 O2 B
full_path := RegExReplace(full_path, “地址: “, “”)
4 Z( a5 S3 P# n- p, F ; Just in case – remove all carriage returns (`r)
" R3 l5 u; ]+ f, S9 F5 F+ P; C+ U StringReplace, full_path, full_path, `r, , all
/ ^, D$ [9 T7 C8 c+ T' O3 \ IfInString full_path, \7 `( S$ G5 i" k' p; G2 B
{! r! k% I, o D- s' m
Run, cmd /K cd /D “%full_path%”# o1 E2 Y- k R x$ [
}
% V- y( m/ {/ f7 d' a/ x else" U. }8 e. K1 r" C/ T* p
{
5 G9 l: m0 r/ ` Run, cmd /K cd /D “C:\ ”9 K1 e# p& A# d' _
}1 C1 ?. Z j, {! l# q- W: G& _
}
( X, Q$ x3 y7 O% Y9 {" ^ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。% T' n# b- ?- a! T6 x
这段小代码肯能有两个你需要修改的地方8 k% V M3 z. ?: W9 W
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
( `2 V0 b$ l- k$ `+ H I5 y. } 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
# S" J Y6 y z* E( }9 Y/ i3 U |