此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
+ \; O- f a* F. ? 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
3 g, m, J# t) u9 B 方式一:
5 h+ b( R7 h( h$ j 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
w" s$ `% i U" Z) ? 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
* p# D! w( i6 {! j7 x3 J HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。4 k4 q: W. k8 G8 y0 z/ m- u
方式二:. r% | s* t, L. w
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:0 J5 h Y( j) v. R6 C
SetTitleMatchMode RegEx
5 J) G$ B/ P: {) U7 v return$ |; G$ K5 r7 j
; Stuff to do when Windows Explorer is open
& o6 h! b( Z! q, S ;" G) L; C1 E2 T/ {1 e
#IfWinActive ahk_class ExploreWClass|CabinetWClass
5 A2 M5 Z/ ^/ s" J$ g6 ^ ; open ‘cmd’ in the current directory
, ~3 J1 ~3 r1 g% n) H ;
: I: F8 P3 B+ |6 I' ]4 p Z/ Y7 H #c::3 c* p* Y2 X4 b4 B* }! S
OpenCmdInCurrent()
% {5 G5 B- j% Z, O, H- \ return/ |$ P0 q9 R% z& r
#IfWinActive
/ v7 w4 C. [: e8 V ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
, n6 _, a, k0 M, n" M' g7 m ; Note: expecting to be run when the active window is Explorer.3 U. _9 M# U1 K3 [. ~7 f M
;8 O; @1 o/ ?5 X
OpenCmdInCurrent()8 y+ k6 P! z- T7 W% w* A: D" l' v
{) f7 K; R- V5 ^2 U4 e' l4 }! M+ L! l
; This is required to get the full path of the file from the address bar
. v1 R. k7 g5 e: f WinGetText, full_path, A! P8 m& O7 z; t, Z0 q x
; Split on newline (`n)& v! i% G$ O+ l5 k. c3 q( T
StringSplit, word_array, full_path, `n8 r" z8 S' s" t8 W+ Y7 p+ t
; Take the first element from the array
3 J2 g+ F# d9 j G8 |! i6 _ full_path = %word_array1%: L, x9 L, Q" O9 i
; strip to bare address
6 F5 f; T/ z9 I4 s' h. p8 z9 A full_path := RegExReplace(full_path, “地址: “, “”): N ?# b7 b: U2 {
; Just in case – remove all carriage returns (`r)
6 B+ x# `" s5 k9 T/ m. E$ b- v StringReplace, full_path, full_path, `r, , all7 @: Z4 c. ^ k2 {6 E* R
IfInString full_path, \, Y/ {" m% }3 k; N( V7 @; X$ W7 B
{, a. }& B% r2 c0 F, u: K
Run, cmd /K cd /D “%full_path%”6 S/ i" c' M" l2 l. i, Z
}
( O1 l6 n5 Z( |& A else
' @ D+ X2 v( @6 o% ]: ~! h {
. P, o& U% ^6 {+ x" i Run, cmd /K cd /D “C:\ ”4 P& R6 P; H/ V# i" {
}& }$ s# Z( ?6 l9 `
}# h: C5 ?; l& L# E. N9 p
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。3 h9 B# {4 W# }4 R
这段小代码肯能有两个你需要修改的地方+ ]9 P0 c3 L+ {0 L0 V* B
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
8 z2 {# N1 C! k( s- @9 q 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “5 {6 C; O x1 d: `" c( f! n0 c% v
|