此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
& p9 |# x$ Y! G- Q6 M2 j3 [ 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
% j9 m( D' U5 }3 `. u) T 方式一:
' ? O: l0 h7 V g$ p 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
" Y; n' k0 a; t" G) h" C 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和7 M6 q' U3 h! M* h# A
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。) @1 O4 B3 M" m. j' ~+ N6 o3 ~
方式二:
+ \8 e0 L* Z6 t3 g- V4 `" Y# ` 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:* G$ b6 q6 d" Q) \ i$ @5 q& \
SetTitleMatchMode RegEx
2 p0 f6 M" `5 G5 ^/ Q0 } return8 g3 C8 ?( |; j ]
; Stuff to do when Windows Explorer is open7 W( `+ d# `! t# ^) w* ~4 v# d
;
& f+ q3 F* D7 e; { #IfWinActive ahk_class ExploreWClass|CabinetWClass2 n" B0 r& _' b7 v
; open ‘cmd’ in the current directory
! J& K" q7 O. T ;% H1 C' ?+ @) \) v+ g# A, H
#c::
7 R. ~% y. O$ J0 f. _; ]3 N8 A4 h OpenCmdInCurrent()4 I; [) v! {8 s& q, z9 I8 U$ l7 D( B
return
+ \7 c& d1 Z# {+ ]3 h# ? #IfWinActive
. Y& I3 P, b5 I' F ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
4 f6 h6 D4 ^) H0 ~/ s ; Note: expecting to be run when the active window is Explorer.! D- |- o7 F4 a& r3 x+ r4 X. `
;1 Q9 {1 e$ w' i( t' j5 y& e
OpenCmdInCurrent()/ i! Z' l H7 I* l
{
. l: {9 Y$ `+ t ; This is required to get the full path of the file from the address bar1 a6 s% Y8 ?) D. A
WinGetText, full_path, A2 v- q+ `: c% C2 k7 l3 S5 i
; Split on newline (`n)( j; f9 g- ?& b. n# J
StringSplit, word_array, full_path, `n
: g* \( o5 T7 ?5 l4 ` ; Take the first element from the array# W$ n3 m2 u) T; K8 I) L2 C
full_path = %word_array1%8 X2 J5 F4 d: `; T- W- y( \
; strip to bare address
: W1 T" p/ h1 Q5 N full_path := RegExReplace(full_path, “地址: “, “”)
* G' D0 b8 N) h ; Just in case – remove all carriage returns (`r)* Q& w( `$ ~6 U) l8 |, S% B
StringReplace, full_path, full_path, `r, , all3 c, S9 E$ X6 y b; I( W# s
IfInString full_path, \7 c- v+ y2 `* f# n: \ p8 y" J
{
! O& v O- ]6 l5 f* V/ z! P Run, cmd /K cd /D “%full_path%”1 D s- [/ @8 C; l: I
}
+ @# C' W7 b! B; F. U& O! A else
3 Y2 b @! u4 ]& \0 ] {* n9 z! I: n" q N! M7 \0 M
Run, cmd /K cd /D “C:\ ”, Y6 e- j2 I2 D4 x
}% U: V; ]# x/ l1 q. m+ C, y
}! a5 @! I/ B% e2 \$ F- c/ j4 X
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
* I" Q1 e# i3 f( h: f( `. f 这段小代码肯能有两个你需要修改的地方
( T* [0 G3 A( `/ K 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键 q# ?4 V. r$ i" f/ T9 Q
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
: J/ q c' B2 c1 _ |