此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。 i% \" w; A, N; d
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。$ a" K- R6 }% [
方式一:9 j9 Z% N$ |6 S. r! T
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,6 v. h; a& D* u/ M, y1 L7 Z! @5 i6 z
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和, m) J9 s) j& S7 J; `- s6 h- ~
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
/ C8 I& J. t( `: ~9 ~ 方式二:
4 x, K! _& a" n- |2 j4 m- h 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
6 _9 N w! E2 j9 G2 X" H SetTitleMatchMode RegEx
4 u0 L/ h. U1 Y' P return/ m8 S% x6 u4 P: j9 D% G
; Stuff to do when Windows Explorer is open! ?4 X: C% Q% w& B9 O' Z
;; l% o9 D' R; d2 ~& m
#IfWinActive ahk_class ExploreWClass|CabinetWClass: A& f' t _" n7 F
; open ‘cmd’ in the current directory
( r# n: Y! H# |, d; _& ] ;
2 r- y% k$ _5 ^8 m% N2 \ #c::, k0 |* N. l* r* ]* m
OpenCmdInCurrent()$ B' b' _& P7 a) v; j
return
9 b. Q; z* h7 t/ I g: H+ E6 s #IfWinActive6 z* d( B* b3 Q9 S7 \% a& y
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
. w2 w) C) b. F' N7 D1 ^ ; Note: expecting to be run when the active window is Explorer.0 K' \* @7 |& m% h5 Y/ d
;4 [5 k1 A% a/ ]& }* P
OpenCmdInCurrent()# ]8 k" y' A6 g. {" k+ {
{
! I9 |" |; A" p" V3 j ; This is required to get the full path of the file from the address bar- s( C7 ^9 M9 P: r4 q) m; b4 L) l
WinGetText, full_path, A4 [% g0 }4 w! z6 f. J
; Split on newline (`n)
2 B! B7 D( c3 R1 X% M StringSplit, word_array, full_path, `n
9 L! h! o Y4 n* a, H/ f: F ; Take the first element from the array
/ [. `$ z* I8 k/ o; N full_path = %word_array1%+ H Y G: X7 p% ^- ?/ g; r) v/ T
; strip to bare address
. _. Q+ p2 x# h( _% d; e, m/ t full_path := RegExReplace(full_path, “地址: “, “”)
0 n* h' a7 c' k5 H0 x ; Just in case – remove all carriage returns (`r)! R4 f4 n+ s# W3 T" T: v
StringReplace, full_path, full_path, `r, , all
2 o. i+ i, ?& [( w IfInString full_path, \! g2 m3 F+ s, J) G
{5 {+ l- L, p" y; ~4 ^6 c
Run, cmd /K cd /D “%full_path%”9 E5 A7 f' F$ x: i; T4 _; H
}. J& S1 ?' @( l7 V. `
else
6 t( _0 F* H4 `& [) |0 ]. l$ @$ I {/ W* A) P/ T" P$ K, [# \1 J
Run, cmd /K cd /D “C:\ ”
& R( N3 K$ _; C# D$ Z }
) }! B [& O4 z2 o; w }) H* R$ `- _1 P2 {
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。$ B7 V6 m6 B8 z$ n% p& Q9 Z9 s; D ^
这段小代码肯能有两个你需要修改的地方; l' h: ?8 h* J; J6 }# J# ?( y' P
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键% _" J ]% `+ n4 O/ c
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
. j! b9 S! B% g* B& V3 @ |