此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。6 ?+ [% b1 ~1 v* _+ `7 W
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
1 w3 z3 r& t' Z- p1 t* V4 @, j 方式一:# t( m* Z" C v8 D3 r0 u
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,) Q2 y0 A/ N* s$ l
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
2 ^( ~/ Z$ L& {+ Z" @1 h2 J HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。+ G! Y& z7 x- I/ Q/ k: j
方式二:
7 a' i1 u/ W P2 P# u6 K( M 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:! d/ Z: l9 i0 M5 V: P
SetTitleMatchMode RegEx
& g) O! D$ ~: c4 m- W return
6 b: W( b) ^3 m" O ; Stuff to do when Windows Explorer is open
4 H( d' k; w% V ;4 @' m+ [8 p4 V1 Q. V) @
#IfWinActive ahk_class ExploreWClass|CabinetWClass, R7 B& @+ V, O' F) G
; open ‘cmd’ in the current directory
l3 f: x! V7 h8 p m5 E! X ;4 y2 K, i+ \6 o7 ]+ q' P8 d$ U3 P
#c::
; m8 H! q) A' n& ~3 \' k0 r OpenCmdInCurrent()7 f* Z! P4 B O; R, i
return
" S+ a8 N' X$ f #IfWinActive
! A3 A8 u* Y+ t# l ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.% t8 F0 a/ o1 l9 \& _+ D/ i
; Note: expecting to be run when the active window is Explorer.
( F G0 @* W. B5 \; C8 n# l ;$ Y3 r$ I& k7 E8 ?, M* }
OpenCmdInCurrent()) [8 V; R9 Y# n7 k
{
: O& N3 l, r" `- j$ z+ Y ; This is required to get the full path of the file from the address bar
w! B- T5 g! P* Q WinGetText, full_path, A
$ Q. _8 @% ]0 t ; Split on newline (`n)& w9 b/ V5 @. y. ?
StringSplit, word_array, full_path, `n0 E" m6 E0 l( W! s* s$ U
; Take the first element from the array
' s5 u( c7 g0 Z: z# S7 c' N full_path = %word_array1%
* s/ S, {& u9 D ; strip to bare address& g' A0 A8 N% ~5 l4 y
full_path := RegExReplace(full_path, “地址: “, “”)$ o+ |, ^$ U$ j9 B: {
; Just in case – remove all carriage returns (`r). G- B$ _0 ]1 F
StringReplace, full_path, full_path, `r, , all
3 I: u3 K7 h5 K5 a7 ` IfInString full_path, \; C5 \6 z4 y& w# m
{9 x7 D; K* T1 t `
Run, cmd /K cd /D “%full_path%”
8 E* e0 Z. \% b' o0 j |- f }
: B, T3 X2 v& Z5 b else+ K6 Y3 e7 X v" k" m/ Q" ]
{ a- G% e9 w, {( w- _
Run, cmd /K cd /D “C:\ ”( k1 A; B' S9 R! ^
}. Z8 R; w" h# d, _
}4 }# U o- ?9 h0 ]1 a
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。4 {: x+ _: K: u8 A$ R1 Y; j
这段小代码肯能有两个你需要修改的地方
3 t7 X- T# C; v) _0 R 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
3 y% D) y! ?9 j o, R8 b 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “! L' @) ?; O, N% q4 }' M% v+ q
|