此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
. Z$ G7 O1 U& S0 c5 H8 H 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
: F" v7 {7 \ K7 m 方式一:! ]! R" x; j8 ]. j6 H
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,0 u# P0 r* n0 @8 n0 N, V
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
% J6 V3 o1 s) f6 j) [) X HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
6 `7 T6 u/ L" q8 V. p 方式二:
2 x6 i0 _) W2 | 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:8 w1 P, P9 Q3 ^* B d
SetTitleMatchMode RegEx
5 [4 N5 P) [! c J2 L) E: }# ] return6 w* a! u2 p7 n* b' k9 n3 ?
; Stuff to do when Windows Explorer is open! H! K" ~. O! A! Y
;
5 c* D2 ~' E1 |' p #IfWinActive ahk_class ExploreWClass|CabinetWClass# {' a0 `0 x9 n# \
; open ‘cmd’ in the current directory3 ~" G7 z+ c( Q0 a h+ N! n
; g/ M* {4 r! f9 q7 w
#c::
' J! z$ [/ r6 m4 E( W4 L1 { OpenCmdInCurrent()! V1 h; R! Y: I1 {7 Y) J/ ?- f
return- n$ G% r9 ]* u7 f$ C
#IfWinActive- D; p+ s6 X- R: D
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.! }0 a, Y$ B' p7 u: c) y
; Note: expecting to be run when the active window is Explorer.9 H* k8 Y- n l. N& ~, U3 j: j5 O
;
8 c+ V4 ~, g# S) R# C1 j* G- z OpenCmdInCurrent(); W# N1 R) z3 _5 B+ D) ?+ r2 u; j# b% X
{
* t( ]; D7 i) I: j- L2 u/ z ; This is required to get the full path of the file from the address bar3 c9 u- H' Z2 d% _, V
WinGetText, full_path, A0 g, B) b2 k+ b$ q: V
; Split on newline (`n)# g. x" T+ c4 u9 n$ ?
StringSplit, word_array, full_path, `n
* T( ~- [0 P0 C: o9 d ; Take the first element from the array
& c$ e7 R9 w; r3 C! E full_path = %word_array1%2 i2 B- z" J' Z
; strip to bare address2 d4 P0 T! c% N
full_path := RegExReplace(full_path, “地址: “, “”)
3 ?2 e5 ]$ p6 n* A; w1 L" E0 w ; Just in case – remove all carriage returns (`r)
! @. D! m" r4 R& e/ F3 U' v, d StringReplace, full_path, full_path, `r, , all
! q: Q4 h: I5 k$ [' l9 i IfInString full_path, \
Y- x1 P- K4 O4 \ {
a0 x% Y5 p f& m8 g5 K' m$ u) V$ ` Run, cmd /K cd /D “%full_path%”: R1 a5 s. m6 T# h9 z; @
}8 b, F! Q* S$ t/ P! ?$ s
else4 b8 B& N) `: h, `! |( F
{
7 f/ Y( M/ _4 z: v2 @# N, k Run, cmd /K cd /D “C:\ ”
" N% V6 f$ b) }, l }
0 i( ~, ]0 W Q7 m+ d1 F! O }
: v6 l; o4 Y2 m4 v' u3 g 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
Q h$ s5 Y! D- @& [0 U 这段小代码肯能有两个你需要修改的地方5 T' s; J& x" p: f3 [( @
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
1 X5 ?2 Y. e3 k8 x3 q 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “+ T; x% B9 `8 [2 P2 O
|