此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
0 a% x( z* W# h$ P 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。$ n. ^. X: ]+ J7 |
方式一:
1 U0 Z3 Q/ c0 H' U& G- R5 }: f S 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
( z' A/ B& ?! c! D, L) e 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和6 {1 U/ M1 j/ M4 _9 Z
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。9 d4 M( A4 T' _2 f7 z
方式二:
3 F g& A$ ?; k! T$ K 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:& ?* k* k- {. {
SetTitleMatchMode RegEx1 \2 y0 o" O) Q$ _$ N2 z0 [2 T
return, y2 ~: t" \9 T4 e' k% Z
; Stuff to do when Windows Explorer is open
$ M- I; |. A1 V U2 ~; L0 r7 f ;! @6 E3 |, D% G# o1 B: ^
#IfWinActive ahk_class ExploreWClass|CabinetWClass0 J" o/ N1 v) o& u( `9 R
; open ‘cmd’ in the current directory. a9 @$ K) m! o- g8 t
;7 z" w4 k1 `$ f0 q/ t, E# L0 B
#c::, D& V, Q. h% N P/ b. m) {
OpenCmdInCurrent()
, l, N9 y7 G$ R return
2 A# W; \' y) t& O1 ?; B( I! l+ N #IfWinActive
* u; X/ T/ j) w5 c) }0 T& y$ W5 h ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
1 O. G( \9 t+ r0 p8 G0 \$ V. K ; Note: expecting to be run when the active window is Explorer.* r+ c. |7 R3 j$ ~
;
7 K: i. r m# k# V1 Q- o OpenCmdInCurrent()
5 N( ~ V' {1 n( v8 d c. { {1 b$ u% ~" T2 u- u2 p" l
; This is required to get the full path of the file from the address bar
( _3 E6 l4 d# M WinGetText, full_path, A9 |2 W p* g& c4 S
; Split on newline (`n)& d6 t$ ~+ N1 t3 s g
StringSplit, word_array, full_path, `n
/ i0 p/ ]" T/ h) Q* D ; Take the first element from the array' V M6 X, h X9 i) }/ n
full_path = %word_array1%
# J" O8 |0 I9 C* w% Q# X ; strip to bare address
* B" A3 x7 I& Y v5 R* r full_path := RegExReplace(full_path, “地址: “, “”)8 V+ W. l$ u# M, R% _ g* d% h
; Just in case – remove all carriage returns (`r)
- W Y2 p' _ ]0 b StringReplace, full_path, full_path, `r, , all
8 p$ T$ ~; l" ]0 s- l IfInString full_path, \. x& t6 ~$ ^& H
{
* ~( p+ e4 u- o/ x) M1 J Run, cmd /K cd /D “%full_path%”
O6 k1 S/ o! k/ X+ j) u }
% A g' P5 x6 p* t, K" |+ Z& ~ else+ P- ?0 s' G$ z0 s& B) @; t) f
{
( ]1 Y( Z9 w" u4 h Run, cmd /K cd /D “C:\ ”
: A( u/ O* z6 R% x& ` { }
& }& T; Q# x0 I5 W% K }
! w0 S2 `/ P, @, d/ D 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
* T5 w. N* ~3 F" I5 O' X' f( _ 这段小代码肯能有两个你需要修改的地方 `3 M$ j; W. |: K/ t8 l
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键, h4 M5 P% @% ^6 e4 h
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
- [; e; |" z% o. I' S |