此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。6 l9 B% u) X& _" c2 D
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。( N) d2 L4 n4 [- U$ x. c; f3 J
方式一:
1 {4 z* q0 ^8 B' h! N: V 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,9 O+ g+ q; E* }& E
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
! K% u3 ^7 d& `! t U HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
8 j$ J; C6 F4 ]2 F 方式二:# |& b' x I+ A& k8 d& n H: Y
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:* A3 v1 s9 v; j& D. _
SetTitleMatchMode RegEx
5 }2 T9 _$ @$ F2 j return
) d7 f, R0 j' h! ^ V9 J1 V ; Stuff to do when Windows Explorer is open
* M, O; k. k1 U5 D A, W# \ ;* ]. y% M0 q% I0 d, U/ p0 B
#IfWinActive ahk_class ExploreWClass|CabinetWClass
8 s9 ^+ Q7 S' z* h ; open ‘cmd’ in the current directory; _1 ]1 \( p, r6 j, o& Y
;
( t' g- r( S! z0 h3 Z: y! l, X d #c::
K7 T( \ b5 D2 Y8 X2 E& W% s OpenCmdInCurrent()
( a0 g- O) A ` return
6 B/ j. ?) o% z j8 x9 ?# G #IfWinActive
' O! l9 @1 K0 s g R) P0 A ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.- O7 @7 O. E8 q6 r
; Note: expecting to be run when the active window is Explorer.
( A# D! f0 D7 |7 x, u ;/ p1 e. S$ g! S5 Q g3 g
OpenCmdInCurrent()) f- l1 S4 A1 ~6 T
{
: t, Q5 M" \2 [3 m ; This is required to get the full path of the file from the address bar
' j" `7 L% X6 d+ f/ L9 i WinGetText, full_path, A5 _) Q: f5 a) }# ^* v0 ~
; Split on newline (`n)
( @1 S1 [4 ` j StringSplit, word_array, full_path, `n( l D3 p# _/ D6 E" [3 z
; Take the first element from the array
; s) u! V9 _( o0 u5 Z$ {5 v full_path = %word_array1%
, r+ X; b+ W$ k _ ; strip to bare address7 d1 B) }, i+ Q* m1 z
full_path := RegExReplace(full_path, “地址: “, “”)
2 @0 L, A |' @6 _) f( W8 J6 u ; Just in case – remove all carriage returns (`r)
, i1 l/ \, n4 q, z# D; H# T# ] StringReplace, full_path, full_path, `r, , all/ \. a5 C7 a' Z; y& z+ G# M
IfInString full_path, \$ b" L0 c8 ~3 A/ m7 w
{
. w/ @7 U# u8 @! T' x0 }. { Run, cmd /K cd /D “%full_path%”
4 H, W. {8 _7 F: ]* k: | }( P! c- v7 l# l5 F4 X
else
3 W6 }# o$ |2 G7 a5 q' \- o {
! |1 ]: |+ E( M) |9 C2 u Run, cmd /K cd /D “C:\ ”
5 o0 M; [3 P9 e R( G }
% i* R6 _1 U. \; c" N$ B; o$ X; g }
& Z8 q7 F) U5 L& Y# I4 A% o 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
" Y$ x+ h2 F: f( l& { 这段小代码肯能有两个你需要修改的地方
# y+ a3 B6 L& l5 X. a! m 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键. i3 M* H4 l& t8 l
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
" y- t8 \1 @$ {2 {; T# w |