此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。# }$ @8 ?& k. @% X- Q8 r$ M
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。' w/ o; v4 K7 V# L4 x6 a
方式一:
: O1 | u; z6 s; _0 W 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
! N$ R2 ?1 A* x* O9 k/ k I% R3 c 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
2 v: I1 N8 G O HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。8 d" M, N7 W. M p( x& w
方式二:
+ v9 t, X9 b! M- @ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:4 F4 [: V/ w0 ]: t" u& T) x% b. P* o
SetTitleMatchMode RegEx4 o4 p+ w6 }) m! Z, O/ b
return0 [# `" M) u! l% i+ c r1 q6 l. o. d: B
; Stuff to do when Windows Explorer is open+ u( A8 @7 ~) |% q
;" p* ^/ q0 F# @) V8 r" ]* X
#IfWinActive ahk_class ExploreWClass|CabinetWClass6 K2 R# w4 X" B
; open ‘cmd’ in the current directory
+ J' M& a7 y. s4 b1 F3 \ ;* ]' B3 [' P4 y0 S, Z
#c::
$ j3 _- W/ W" G7 ^ OpenCmdInCurrent()8 Q- E8 h2 v0 x+ _0 r/ [3 b
return
& y" @* t* {& m7 g #IfWinActive
. L+ e: q8 M: x) \ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
5 q4 I3 Z& E/ S3 D ; Note: expecting to be run when the active window is Explorer.
* a! S; d* G: X ;% v) c+ ~# C# M& w/ ^$ S
OpenCmdInCurrent()
% u1 q) V5 l! U$ k9 E) J {4 t4 I# b. S$ }9 [4 c
; This is required to get the full path of the file from the address bar5 U; x5 w3 } w! ^
WinGetText, full_path, A
9 v0 Q0 N7 Z8 w" P ; Split on newline (`n)
/ D8 z1 V" o7 r, O StringSplit, word_array, full_path, `n; Y8 g# i) ? [, h& u. o) z
; Take the first element from the array! M; O1 j* N5 [
full_path = %word_array1%
+ |1 S8 \" B8 i ; strip to bare address
$ w( m1 z4 T5 k2 E$ p full_path := RegExReplace(full_path, “地址: “, “”)
+ t/ ~ l% \' \; q% m+ S ; Just in case – remove all carriage returns (`r)4 |4 Y. `: _3 z* P% `* R
StringReplace, full_path, full_path, `r, , all
- u( b/ N7 x. g" ` IfInString full_path, \( B. E ]' a& ]0 N7 _" {
{
; E1 y! x0 \+ P* n9 H Run, cmd /K cd /D “%full_path%”8 \# G4 F, z# W. k/ J4 M. ~2 Y
}0 ~! C* U3 m9 n7 ]% Z- M8 ^8 n
else
# p; c6 [9 L# \ W4 F3 |+ P {) S) S% T9 z% B, C7 w
Run, cmd /K cd /D “C:\ ”9 @3 `' ]4 F3 ^% K2 {# J
}
0 V/ A) I6 s. K* `, \% p! i& L }
3 r) ] x/ I: M/ s 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。5 R% H2 P" d7 F( {% i5 C
这段小代码肯能有两个你需要修改的地方9 s" P! U \0 n6 M/ }+ E8 E
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键' P/ Z% ~8 O8 d2 Q2 ~# F( \4 S6 O
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “; z# n3 X% B& t: H) K
|