此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
- _- @5 m1 g" E D 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
o' w" a6 B# e/ m4 a3 q 方式一:
0 r$ B g" @1 |' ^ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
) a! R& v t4 ? 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
& h9 P7 p% v- N! x HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。3 U5 K6 F9 X+ k s% P) R" {5 J
方式二:
3 l9 M2 W0 x" x 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
& s. _1 R& {9 c( u" v+ R) D SetTitleMatchMode RegEx
0 K; s/ g, o2 K d" X return
8 q, S- b' \4 L4 o: [ ; Stuff to do when Windows Explorer is open! T/ }7 q1 X3 q- N! ^* ~6 b: N8 y* O
;& y* P- `" M# a n
#IfWinActive ahk_class ExploreWClass|CabinetWClass
$ Y! B, B8 I4 N* v! s$ J' b ; open ‘cmd’ in the current directory
4 D" x- N5 Z8 _* |6 R5 u3 j ;
R) K1 Q& l4 v, X g #c::
0 v0 n8 c6 r3 ^& Y/ w OpenCmdInCurrent()
# F# K* K) R& ^ E; W* P& C1 o return
$ b# i( B6 @" f( I" U #IfWinActive
% R2 }" S! J% z/ k/ F( B ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
, {+ G; u3 w# a/ A% b% B ; Note: expecting to be run when the active window is Explorer.
8 Y& [! Q. k% r) a3 i ;9 c3 ^' J, |1 }6 i3 X) | h3 k2 t
OpenCmdInCurrent()# }# }$ T$ j0 n9 K6 V" p
{* t$ X6 b2 A! C3 e$ q
; This is required to get the full path of the file from the address bar+ }3 O4 f4 I; \8 S, `
WinGetText, full_path, A, s1 o5 ?/ h0 D5 Y8 T& V; i
; Split on newline (`n)* A( H' y7 O/ _' M9 y5 p
StringSplit, word_array, full_path, `n7 g+ ?4 [' Q( X7 V! Z/ k
; Take the first element from the array
0 b8 J: a2 W( i5 U8 @ {. X& h full_path = %word_array1%$ X2 ^. x2 e* O8 N0 T! b
; strip to bare address# i/ y% t$ q, ?3 `. J- b3 z. S
full_path := RegExReplace(full_path, “地址: “, “”)/ @$ T; J7 b/ m& g9 [
; Just in case – remove all carriage returns (`r)" W7 e5 q: K( K9 r8 Q7 d" K
StringReplace, full_path, full_path, `r, , all
$ I3 ?, ^4 j+ |6 { z* Z IfInString full_path, \. y# `! b% M9 I& p, f7 f
{
, d0 }: y, o' ~7 ?4 ~ Run, cmd /K cd /D “%full_path%”
$ g1 u: P- S; ?; A8 i }# ^. [; c( {5 L, A- q3 h
else v7 ~9 u& Q$ t. I+ o8 k, j8 Q
{0 [* f$ j# e) a- g$ P7 B# _
Run, cmd /K cd /D “C:\ ”) @# v! i+ C0 Q' |" ?; D3 {
} J O5 \% q% {. T! Q8 k7 { V
}) }2 ?* k3 |8 |
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
/ }0 g0 X% e9 _/ ?- E4 z 这段小代码肯能有两个你需要修改的地方1 e/ s+ R5 s& T" L/ r2 {3 m& i. H- b
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
) F4 N% A' M7 _* B& [; `% @6 x 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
4 i3 [( d- T3 g: j |