此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
: x# C+ ?% G! l0 h) H2 e5 q2 W) o8 _! j 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。7 ^9 [ ]- o+ {3 ?: A
方式一:6 t0 B9 i( G! n
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,1 W$ Z# Y8 l! w8 _1 h" i
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
: s3 ?, U! x" J8 H' l( [' ] HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。 V0 U) C6 ?. S2 D( H" y
方式二:
+ ^) R, s* k" e6 x$ ^* @- A 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:. A# \/ U: z$ X6 m
SetTitleMatchMode RegEx
. A9 \% j0 q" t return* [, F( k6 T5 D. W
; Stuff to do when Windows Explorer is open' c/ i. |; x9 ?. B' Z
;
! U: W- @5 W- {% e0 J+ g- G #IfWinActive ahk_class ExploreWClass|CabinetWClass, W$ W6 c" C7 C; o
; open ‘cmd’ in the current directory
' r1 J! m5 o1 B; ^9 } ;- C7 ?: W+ v& c' w& w: ~7 A
#c::
0 F+ G8 C% v) H' w3 D- h OpenCmdInCurrent()
2 B# F3 s; f; B! ]; n& Y/ F9 V. a return
0 G! N' k" N! H2 k: } #IfWinActive& D+ X. F( b$ Z* ]8 ?
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
6 O1 W# {0 h \& V; | ; Note: expecting to be run when the active window is Explorer.
2 I) U. u. s% O' M) n4 X ;
5 k0 O4 r) O' s) t# ^ [+ F OpenCmdInCurrent()9 s% D) X: a' M0 _; ]- D
{3 S5 m }- ?3 N0 b
; This is required to get the full path of the file from the address bar
3 E: W) H. x% R4 z% o WinGetText, full_path, A
f. l8 Y* z u0 A& G3 Y* }2 _ ; Split on newline (`n)
! \! q# K! N# w' r2 T _7 s StringSplit, word_array, full_path, `n4 Y& k7 Q R3 L4 l# z9 u
; Take the first element from the array
8 Z5 X3 @; \$ `/ ?1 Q3 X- d% d8 o8 y: T full_path = %word_array1%
9 Z- F+ _: Q4 Q. o. t) x ; strip to bare address0 B5 P, t7 l- h: ]. t2 z
full_path := RegExReplace(full_path, “地址: “, “”)
8 X0 c5 ?7 y1 k. M7 S2 Y# T4 ?# q ; Just in case – remove all carriage returns (`r)
5 g5 e" z1 A/ I' V StringReplace, full_path, full_path, `r, , all" T$ W. L( f. c ? f! `3 c; D" _
IfInString full_path, \- \# k) e: O, O" O
{
# m4 b, B6 n% | Run, cmd /K cd /D “%full_path%”) j0 @! z' o# G! U# }' e# l
}" S9 R! t# k# \9 ^" y
else
3 }* r1 @; e! r. K% z- ^ {, y' Z$ M4 D* g
Run, cmd /K cd /D “C:\ ”7 C4 ?/ `( x2 e( I }" \# h
}3 h) V. l3 t3 H3 I$ D
}
' B8 j8 q/ H/ ]5 a, C" u) d 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。1 v7 _% ^0 c3 r |
这段小代码肯能有两个你需要修改的地方: Z, q* @/ A: D/ R7 k
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键/ m6 Z, H" W" ^8 T' M( w: o
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “# S% w5 Y. Z, H9 N4 q7 E: C
|