此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
; q9 Y L7 p( @ 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
8 _; Z3 _$ W+ w+ I6 V 方式一:
# c& E8 [- E, e 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,9 J8 ?; q& R* n ]" O
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和' ~# W( R9 P) x8 |
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。. I8 e1 @" o: G# T* i" a3 N& c
方式二:& c# d) w4 S9 M, K# R: i6 |& Y
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:, N* j8 i, U: ~' c
SetTitleMatchMode RegEx
" e8 K% y+ H9 t return
# m! A" w: E4 a# h ; Stuff to do when Windows Explorer is open
5 `1 q" @' g* a ;
; R0 H" a0 x, T" p3 S' R$ x #IfWinActive ahk_class ExploreWClass|CabinetWClass
* B O* E4 s0 k" e0 s ; open ‘cmd’ in the current directory
' w- O) ^ k$ u2 l' z. z1 ~ ;" X# X9 N6 F6 c6 t
#c::
$ `7 a9 P' b" N OpenCmdInCurrent()
/ m; c% s: N! U1 S* S, L) K return
! f Z- ^8 d0 [$ \ #IfWinActive1 Y* t( F6 q6 a) q! H" _
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
2 u1 c. W! @' s ; Note: expecting to be run when the active window is Explorer.* D1 E: c2 _! }- }) E
;: Z3 k1 K! l8 V; G8 ?% K
OpenCmdInCurrent()
( {6 q. G+ r9 U {" }/ C0 Q& [, Z. m
; This is required to get the full path of the file from the address bar2 O5 j. L. }/ m9 A4 _
WinGetText, full_path, A* w! t9 `# \3 n+ ?) I7 J2 l1 B
; Split on newline (`n)
6 D; ?1 o* O7 H" Z* e" I StringSplit, word_array, full_path, `n3 j8 c3 h" L3 s/ O( Z/ ?
; Take the first element from the array
4 L4 v- c8 n" \) R full_path = %word_array1%
" O5 d% k' U! m& ? ; strip to bare address" _' s$ c0 L! Z1 y
full_path := RegExReplace(full_path, “地址: “, “”)
# C% d! B, r& f7 }( B. n W ; Just in case – remove all carriage returns (`r)) h- m8 l. ^3 n) E5 a9 t C4 T
StringReplace, full_path, full_path, `r, , all
$ O; Q4 V( M5 W* U, V IfInString full_path, \6 o, K6 f/ t/ W6 }8 @- {$ P
{
K* K0 M9 Q; L, s4 w Run, cmd /K cd /D “%full_path%”% z( v/ `% b3 q' J7 s) w1 `) \) O
}6 `2 u3 R$ |: a0 [
else
, y; c* k5 r, Y9 p2 R {1 i6 j) U, I9 ^# `# ~
Run, cmd /K cd /D “C:\ ”
E( @! w& U! r4 k% N }
5 C: w& G! ?* w7 h# s }
A4 ?7 ^% ^0 t' Z$ m$ y- l 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
4 E' J. p3 v5 b 这段小代码肯能有两个你需要修改的地方
5 f U4 }3 j4 u9 r 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键3 M% C, B C% J+ b( ?/ Z
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “0 v7 w+ a4 m! y7 g. K: }: `
|