此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。8 U8 Q- e" c; g7 n$ C& W" X
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
/ W* v* z; T9 I I) u3 O4 j 方式一:6 u; Q: q' [; ^( X
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,+ C( W8 N, t* B; X b5 M c
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
! E& B4 Z$ ?7 u3 S7 Z& d I8 k# f m HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。6 Q$ Q8 w& o3 b6 L4 G5 S; J6 \# T
方式二:* z* o: F' g7 a; ^' W
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
^9 d X% z3 {8 B8 F+ s; ^ SetTitleMatchMode RegEx8 f/ O6 r9 I2 [) p* t
return' D7 g6 ]9 n+ M% I: _3 `5 |
; Stuff to do when Windows Explorer is open
0 `# }" s( g0 l6 ~3 f ;
& b. H. l4 v |" }5 }" f #IfWinActive ahk_class ExploreWClass|CabinetWClass
0 q7 C0 @/ G$ a g( \6 o ; open ‘cmd’ in the current directory
! }7 G e# h a6 j ;4 a |0 ]0 d3 G
#c::0 @7 v+ N1 A+ d4 E# G# _
OpenCmdInCurrent()
8 t8 T; S1 P0 I8 O, i5 _ return
: J- S6 A/ N4 j* _1 A #IfWinActive
- p3 y$ V8 s5 f9 `* n ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
2 l! h) U+ }/ j# l ; Note: expecting to be run when the active window is Explorer.
9 r' I, ?( ^8 O: S. n% w' P ;
& F& i/ r4 D/ c6 h1 a; q/ J OpenCmdInCurrent()
8 V6 `% M' g* V# y, o {% P+ W5 ~2 r' f0 M+ p
; This is required to get the full path of the file from the address bar
6 e8 G( G* U$ S& U0 o. @) z WinGetText, full_path, A* f" Z* x8 ~3 \; h3 t/ R
; Split on newline (`n)- o5 Y* e3 t% d
StringSplit, word_array, full_path, `n0 }& u; x1 j% n
; Take the first element from the array* V W( b/ S( @0 O
full_path = %word_array1%
& f m* {9 N: ^/ [ ; strip to bare address
. M7 p/ _8 A8 A8 @' F% B full_path := RegExReplace(full_path, “地址: “, “”)
2 @ q2 w) b$ J6 t+ l R' O ; Just in case – remove all carriage returns (`r)3 x5 \0 Z% x) h+ b6 L( ?
StringReplace, full_path, full_path, `r, , all
) ^) m( K1 L, V3 h' C v IfInString full_path, \, l* K7 C+ R) z" ~* C
{
3 X3 R# P& N. ?: k- B8 g7 Z Run, cmd /K cd /D “%full_path%” w! S& [$ q$ v& \9 ^8 @: k
}
4 q2 e- s: v- b, I/ G2 ^! M else' }9 Y* s( [$ E# ^
{
# a& a+ ?- ?( Q5 d/ }& y) r Run, cmd /K cd /D “C:\ ”
9 g& D9 M3 w6 E( l% q }+ O3 l" V2 J9 _* r' S
}
+ Y; G% E( v& r0 ~) o" t/ i 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。) b; N% w; }- n1 {
这段小代码肯能有两个你需要修改的地方 ^4 N+ a* b, @- H8 B% K
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键+ r! R: q* z u' { e( n
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “" ]6 }0 q. b, [, S. }5 d
|