此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。! o+ [5 A3 s- g6 g
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。( I0 b) w2 d; J' j( ?* v
方式一:
4 y! ]$ Y8 P9 q: J3 Z0 z 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
6 ~0 c2 M9 X3 D9 i0 i 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和2 C9 n$ y! S$ F, z) N( P/ d. y0 ~
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
" L0 ~: D7 \% V) y( T3 b* W" H 方式二:
- C$ `( _: o h! i$ M2 r: T; m 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
, J; u0 E- i8 U SetTitleMatchMode RegEx* g5 P" J* V, ]3 p/ \. m/ l0 o) w
return
5 O8 F8 @: w' n; Q6 h3 ^ ; Stuff to do when Windows Explorer is open1 Z6 k! c& ]! R I1 t+ s
;
5 D( u' N5 M) p! U# Y) ^ #IfWinActive ahk_class ExploreWClass|CabinetWClass3 d; |2 u, c# o8 O$ Q7 m5 s
; open ‘cmd’ in the current directory F4 b; P0 u" s" h& w
;
1 C0 @8 v9 a& A5 o #c::2 g2 R6 n: ~- `! K5 V6 }
OpenCmdInCurrent()
6 E7 r- i1 |2 M# s+ G: P8 v/ \ return; x# G2 \0 |6 ]% T% h& r
#IfWinActive d* e+ l, `, ^% p: `; h( I0 r
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
5 F' \7 R! K7 h9 P. _& s ; Note: expecting to be run when the active window is Explorer.
& H9 C" d7 u, _; u" g ;
$ f, G9 h% H6 t# x2 ~; S/ B3 Y& D OpenCmdInCurrent()
6 `3 }$ u& h3 m: \ {( L8 s1 Y7 o- k
; This is required to get the full path of the file from the address bar
5 k( q4 f4 W G3 \2 U, J+ F WinGetText, full_path, A- A* `$ y" X. Q; d; e
; Split on newline (`n)1 w- U7 o L7 w+ v: r/ T
StringSplit, word_array, full_path, `n
! a1 n; U9 ]/ T, U4 @% L$ K ; Take the first element from the array
; w' m9 h+ s9 r8 r% I9 u full_path = %word_array1%! n. [7 N& e% T1 s$ O
; strip to bare address( U% n8 a8 a! n6 x% b5 z
full_path := RegExReplace(full_path, “地址: “, “”)
* K; v" P# @; @* ?- D$ K# \. a ; Just in case – remove all carriage returns (`r)7 C5 J8 [, s( Y7 z; S
StringReplace, full_path, full_path, `r, , all
[, S% h0 y+ P) I, ? IfInString full_path, \9 b/ l. e+ M4 d4 G+ O# \! I7 M; g5 W6 [
{7 h' [$ W& ^- W) p
Run, cmd /K cd /D “%full_path%”" y7 H1 E" M' `8 F G
}
" X7 B! C) z7 E) v$ h7 z else
$ |- R. X9 {8 }7 `) p* \ {5 r# K( B& r5 D) e& ?$ P& V
Run, cmd /K cd /D “C:\ ”
$ U) V) A F+ e" M }7 U. |" ~+ M+ }
}7 ^: f" G7 k4 d+ b6 y8 Y) B
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。 i- d: C6 _ {8 J
这段小代码肯能有两个你需要修改的地方6 L! u7 O: k$ [" p8 }
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键* U; ~3 r1 _! W- L5 A
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
9 t0 U5 _, r. G& \7 Y2 | D |