此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。$ A: m; k+ h' V* M; P' ~
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
$ B7 `# R( d8 V6 M, n% i 方式一:
* |4 k2 D0 l7 d# [4 D& c# w 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
* g1 w# D2 {* n5 J 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和# q+ X9 |. r' u
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。" }. S+ G; f5 o& [
方式二:
0 |4 M4 I [0 a. Q4 G 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:4 C$ ]" r3 E; ^& [
SetTitleMatchMode RegEx8 P% B2 J( e1 S" g: r6 L- V, r, c
return
7 q7 S# j7 A3 F3 g0 i _ ; Stuff to do when Windows Explorer is open
) L: z* w$ [+ c ;# S& l b6 `% k; Y8 |1 C7 H' z4 n2 P
#IfWinActive ahk_class ExploreWClass|CabinetWClass
) w2 o* C1 Q6 q& `' e ; open ‘cmd’ in the current directory! y& U( B3 f$ C9 Q
;
2 D2 |: x; P3 Y E% |# R. F #c::& X# t5 X: |3 J4 s& p+ I8 p
OpenCmdInCurrent()
% r8 k+ t, T6 s8 b0 j0 i# r9 ` return0 s& p" b5 F" l
#IfWinActive
" k* T. {; x! V9 t ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.6 k: {% P. n3 O+ d Q
; Note: expecting to be run when the active window is Explorer.
' q/ n- v3 y" X. S( _% w ; J8 C7 S$ D' R4 f
OpenCmdInCurrent()
/ o1 u7 X" E& p* \ {
/ v) I* G" t C3 u2 o ; This is required to get the full path of the file from the address bar
) o& Z. W# Y( G6 B WinGetText, full_path, A
. ~. o- R! o4 @9 H ; Split on newline (`n)
2 R5 G4 I1 {5 Q StringSplit, word_array, full_path, `n
4 H8 F+ t6 l% _' t8 c ; Take the first element from the array
S, Q% u6 z9 |: Q3 w full_path = %word_array1%
X. L' k" }: z6 O* V' U+ x ; strip to bare address/ S8 i. y. Z3 |5 F: |# ?% r4 ^2 s! n$ ~
full_path := RegExReplace(full_path, “地址: “, “”)- R6 T* m: j6 z, X. B6 A
; Just in case – remove all carriage returns (`r)2 v8 i/ K. A. R% X+ t& h! l
StringReplace, full_path, full_path, `r, , all
; j; E) F3 ^8 F: b/ v2 w IfInString full_path, \: c, N. z T' V1 i1 ^) F
{
( T7 l# ^$ ~* B# g Run, cmd /K cd /D “%full_path%”
$ Y; c# ~8 ?. z$ y& v7 |5 M }5 g! T8 P1 J T9 q- y, r9 `
else% A+ G8 R0 G. b$ E
{0 T. K$ H4 C0 o3 `& q
Run, cmd /K cd /D “C:\ ”
6 ?$ B4 p# L5 C1 h% R1 Y. h& Q6 W C }
* q6 H2 D6 L0 _$ M2 F }. h8 k; s1 ^' Q" [4 @( ?1 M, B2 E. ]
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。) [: @7 u% R8 o* ?9 g" [
这段小代码肯能有两个你需要修改的地方
, @$ `$ o8 D, Y8 ~5 O5 c 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
3 Q [4 v w0 S. u( c/ B 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “9 Y( |9 c! Q: w. b6 h& ~" a! {. N
|