此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
. ?$ \4 M( t2 C# P; _ 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
, y' J4 J, G/ O' N' I1 Z( ~+ u 方式一:
: Q0 l1 o* ]/ u8 I" G2 a4 c 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,* a& l9 A$ @4 }- A: d% s
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
\' n& H+ k5 e7 T/ s8 `$ H# P HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。3 _2 k) ~ T1 F1 {3 ~; M, [
方式二:
- W( j, D. n' P: n5 U9 C$ k. B 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
) x" [8 a0 } J SetTitleMatchMode RegEx @& i! P) _* Y! u4 a* s5 i6 w6 ~
return( |* q4 F% `5 g1 q3 w
; Stuff to do when Windows Explorer is open
4 D, @/ l. F( D+ }) {3 a5 O8 q4 W ;
( p8 V; c# K2 v( G) O' K e/ x #IfWinActive ahk_class ExploreWClass|CabinetWClass
% t' R+ X8 v2 k7 M ; open ‘cmd’ in the current directory
3 [2 x! `/ m# p3 u, [! p j) U- f ;
( E) U8 c. v0 i2 Q2 ] #c::; x/ N# k$ E, L) D
OpenCmdInCurrent()
' C1 F" a( P* P8 u! H: k# H6 \ return, f" i6 O2 h% U5 \0 f
#IfWinActive
/ X7 A/ p# I* }; f6 ^4 R ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
4 w3 I) M( b) p+ ]9 C+ Y! r ; Note: expecting to be run when the active window is Explorer.$ O z' D) M r7 q
;
; J0 x v) a& b) m7 H; t, ^ M OpenCmdInCurrent()+ a4 a0 f/ `# z/ Y
{
2 i) s/ f9 B! [9 a' F* b; g ; This is required to get the full path of the file from the address bar
2 u+ c& M9 ~5 @5 Y v% g/ p- W) w WinGetText, full_path, A) Z2 j* h0 M% w' |7 j* a! D
; Split on newline (`n)5 Z7 k* o" f6 Q* x/ R
StringSplit, word_array, full_path, `n7 ~5 |8 B4 _& t+ ]2 e4 Q& y! c& M2 f
; Take the first element from the array- v- m: z( z& y Y
full_path = %word_array1% H5 ?' }5 g; D8 m L0 z& X/ ~7 v! Z
; strip to bare address
$ B1 \4 t. ?, g3 {0 s( q5 j0 ] full_path := RegExReplace(full_path, “地址: “, “”)
( D' `; Y8 X" p4 | ; Just in case – remove all carriage returns (`r)5 s; ~2 J) g V
StringReplace, full_path, full_path, `r, , all
" j4 W) D6 S6 h( j; E IfInString full_path, \7 n* f, T0 {. ~% v" j9 i
{
! i K" ]* X% H: R' N8 g Run, cmd /K cd /D “%full_path%”6 D3 _; y. w& N8 h. r4 k
}
$ E1 V0 b+ R) n4 e4 T2 D( B else. i8 _2 G7 [# D: i5 {. j( N2 D
{
# Y4 n* F2 k, \$ O/ }+ T2 e; R) m Run, cmd /K cd /D “C:\ ”, f* o# f- C3 [& s5 x9 L) O/ D+ a5 ~
}# n; |3 s. _* u* r- ^# l0 u# ^
}6 ~; K5 h" k0 z! p* v; y% O
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。- z, W l8 G3 x9 B: r, ]
这段小代码肯能有两个你需要修改的地方7 V# z, E% @# {- p
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键" a3 p7 E8 z7 w. t/ n. {$ U; ~2 \& m
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “. k; X6 n' o+ ?; Z( V
|