此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。" J5 K6 |# \" f/ k' {1 h% i
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。4 Q0 D- e; s: u9 C) A, `/ A
方式一:; u W0 ^' q5 @. ~" C; X% `
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
7 ?! D7 o; |$ B 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
! @, s' o+ T% _3 ~2 G1 D H HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
- F: J/ S/ {2 I% r 方式二:
' J* I, T+ L6 w7 v0 m2 Y 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
. u7 z5 T4 B$ E3 h; f1 p SetTitleMatchMode RegEx. `. v& A2 W$ R% b1 t' w
return7 n" G5 ]$ b. A
; Stuff to do when Windows Explorer is open
6 m5 Z5 b" n3 k3 v' I ;6 W5 t+ D' \. i6 W& g
#IfWinActive ahk_class ExploreWClass|CabinetWClass: p1 _# g* X( A! k, ?! p
; open ‘cmd’ in the current directory' k, J3 g' j: C4 {; H" M& b
;
/ S( S0 B' W8 B0 \$ ]/ U #c::
+ ? l2 F0 ~! m- }8 X, F# U, d OpenCmdInCurrent()" f* B$ U( A2 P/ h' L. M! p
return
; i4 T; G% J# K7 A, f #IfWinActive/ H8 Y8 `4 J: r2 W+ P5 l' w
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
8 P% N! N/ f/ o9 P% F ; Note: expecting to be run when the active window is Explorer.
u2 k2 o* H8 k$ K2 {# I' B* E ;
& Q! p8 I+ I7 ]& D* [ OpenCmdInCurrent()5 R& t f. b* Z& l+ D4 n, e/ ?% L5 A
{7 b! C& t& }+ e2 P* \* u
; This is required to get the full path of the file from the address bar
5 l9 F/ f9 g/ l4 N* q WinGetText, full_path, A8 E) [( z$ x; R. Y
; Split on newline (`n)
& m% v: O l* {" V StringSplit, word_array, full_path, `n; @% D* R. u+ B$ t9 T; f) Z
; Take the first element from the array
, B% ?$ L' r3 d* U# z full_path = %word_array1%& u* |6 i& |: k$ F
; strip to bare address8 e- W" b F9 p
full_path := RegExReplace(full_path, “地址: “, “”)
) n# B2 X/ ^ ~. G/ _1 k ; Just in case – remove all carriage returns (`r)
' `: c2 o3 ?' {0 {/ e4 T7 G6 j StringReplace, full_path, full_path, `r, , all7 V% S8 { Q7 v
IfInString full_path, \
9 z& G! p8 D0 @ {
' o( L7 c/ q1 d% x6 Z0 S- b4 A Run, cmd /K cd /D “%full_path%”
: P) i2 L' K/ t# ^ z6 j# g }
" u; u* B0 l0 }7 | else
! c3 C9 w# {% T {; \& X" j; n$ n t; M
Run, cmd /K cd /D “C:\ ”
Z9 H3 O# \9 h" S7 o' { }
. Z' h0 z z8 l9 G" u J) f }+ Q; s" }+ F T
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
0 ~- J, b: j+ h& v6 M5 p9 k S 这段小代码肯能有两个你需要修改的地方
8 @( H7 f; A3 E, U% k7 n" } 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
; O; O) e+ |5 x+ e; l1 P, U$ a 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “. k# s7 Z9 Z2 L- p9 j W7 i+ D! x
|