此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。% f; H- h& s t0 k0 [
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
2 B# f0 U, n* e1 Z) ^$ \8 t 方式一:+ {$ C9 b/ w2 _7 C! o$ g
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,- [0 ]& w+ D6 e5 p* q' k/ w
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
( O L* c- Z S HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
& w" X% m5 X* l. X- ]" M+ T9 W7 [' ]/ q 方式二:
. e1 V4 ? @4 l3 v 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:3 e5 S/ z8 e- l7 h, E+ o% E6 c
SetTitleMatchMode RegEx
4 @9 V) a9 ^4 B5 W, W H) U+ } return9 y0 R& H8 n/ r9 ?" ~/ }' j
; Stuff to do when Windows Explorer is open
( M5 j5 V' ^" n: B+ S5 s# v ;
% G( S# c0 V" U& S$ L- c V #IfWinActive ahk_class ExploreWClass|CabinetWClass) R9 x7 y' @& F1 j4 L$ Y
; open ‘cmd’ in the current directory
4 ?* W( k; n9 o) A ;
9 y1 h& |/ X# L0 F8 ~' V9 v3 k' W #c::
- W& ?) ? {# v6 o. T OpenCmdInCurrent()- z) U0 V' s4 d4 m; J" |0 j
return
' B( B- J1 R' z5 s2 x #IfWinActive6 ?3 \" g. @- S2 l1 Y0 u C
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.( S0 `& l7 {$ z0 o: X( [6 V
; Note: expecting to be run when the active window is Explorer.
5 x* m' c+ w" D- B! W ;
7 y) N: _* T' c/ ^: I5 X OpenCmdInCurrent()
; C/ T5 I0 O' _, V; A, f& C" \) { {
$ f5 {; c7 A. d" d7 w ; This is required to get the full path of the file from the address bar8 Y( j M3 O& s1 I: z% i
WinGetText, full_path, A, v) P. [% X' L, `
; Split on newline (`n)
# s% b% a0 ?& U2 a" a6 @ StringSplit, word_array, full_path, `n
# M% f( g) @/ v+ C# w3 t ; Take the first element from the array1 U, }5 u" v# G/ E! ?
full_path = %word_array1%
& L4 P, Y6 d% {- I6 X" C( R ; strip to bare address' F r7 f5 k. a5 k% _2 h$ x4 u2 S; T
full_path := RegExReplace(full_path, “地址: “, “”)
6 B1 `2 m; N5 F9 ^0 V0 Y ; Just in case – remove all carriage returns (`r)
& J% i, B: }; N9 F StringReplace, full_path, full_path, `r, , all
! t$ g" W# `+ }8 a5 R k! ?! z IfInString full_path, \, d3 T% o1 R4 s8 A2 f
{
8 M1 A) l$ F1 L0 _1 g1 U* ~" G% S Run, cmd /K cd /D “%full_path%”* c0 A+ {! R0 {
}
2 Y1 M2 a Q5 ^ else
" b+ `1 r0 S9 G4 l- u+ n. R {! \8 M. _% u, Y, f9 Y7 E
Run, cmd /K cd /D “C:\ ”
' e8 p7 u% t' K5 H }
/ y' m3 [7 q1 T; k- i& { }
) v" {" R9 ?2 [) G 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。( b0 x( V, q6 o( Z" ~1 L: p
这段小代码肯能有两个你需要修改的地方# \+ [" B/ y: J' p
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键: O7 x9 b: z2 r% t5 W
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “1 i0 ^; @+ [. D5 ] B u B
|