此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。2 h4 w1 {+ j/ @1 [$ k5 d4 ], |
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。: R! ^# T$ x. H' \! @
方式一:7 ~! p2 U7 y) G
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,* a) j( t. c2 S; W
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
+ ]& m% j" T4 _' n2 N, H v$ p HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。5 W, r. B) A' T3 {- P3 ^
方式二:
7 f# O# u. ], x0 ]6 @4 ~, T8 }! V% Y 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:- a$ C3 \7 q; S1 j |
SetTitleMatchMode RegEx( r3 v/ q& P; v+ u I9 `" V
return! x* ~$ D) h. s) D
; Stuff to do when Windows Explorer is open
9 |$ r3 L6 i1 p- r8 s0 N' | ;! o Y2 N/ ^6 s- h
#IfWinActive ahk_class ExploreWClass|CabinetWClass; V1 x. ]) \1 x& w
; open ‘cmd’ in the current directory
# u8 i9 ^( P8 ~! D4 x ;
5 V* V1 l' w. r8 @7 j8 i #c::
& c4 B; E0 ~" w, E2 C OpenCmdInCurrent()
/ B5 T2 D1 f7 _' B return
( b/ d1 y/ p5 U8 S #IfWinActive
0 ?6 R9 H z ]9 Z ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.- j1 Y- M- i) y" b6 ]' P
; Note: expecting to be run when the active window is Explorer.
* T2 M6 u7 V. v3 u4 O& Q" d ;3 r4 _7 Z5 J1 a. m4 Q ^
OpenCmdInCurrent()
3 O5 h! s; W) e( S& o' W. ? {) G+ a4 s5 N8 L( p
; This is required to get the full path of the file from the address bar* w4 E, d0 ^4 i" | |: X* P! R
WinGetText, full_path, A
- M; z8 j! \5 q+ S& m ; Split on newline (`n)
. M: |7 Y1 o- }- X StringSplit, word_array, full_path, `n
8 R% E% N) f7 d A) K" g ; Take the first element from the array# v3 ?/ ^) Q' D6 _% Q
full_path = %word_array1%
. z7 X& ~3 {1 H+ L+ l ; strip to bare address
5 M: H4 |6 \: O# @2 M# f full_path := RegExReplace(full_path, “地址: “, “”)
, w9 g5 D* H$ S ; Just in case – remove all carriage returns (`r)
% d4 R# b" \' z StringReplace, full_path, full_path, `r, , all- [! D/ Y) ?! V7 n( M
IfInString full_path, \
t' S- G$ ^+ a S+ y3 O2 p" E {( j. N4 c5 e. }$ |) u% }
Run, cmd /K cd /D “%full_path%”
4 ~3 \) j1 O' u7 m* F) z+ Z }+ n( ] ?8 Z4 Z' L# m9 l
else" b, ~: D6 _8 ~4 R1 Y9 h
{
5 Q$ ]& S* ^- m& r Run, cmd /K cd /D “C:\ ”
Y+ J7 q! w4 o3 X- W0 Z7 W }
) @" L6 Y+ d# s9 n }
/ H/ b' [* X' k9 _/ W 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
) t# a5 W- r4 N1 e, j& x4 u% q 这段小代码肯能有两个你需要修改的地方" D" R- i [. `0 S
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键& @# R6 r# f& l- p
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “) S( u5 N; W t! M3 ] n+ E( d
|