此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
$ q5 _: @3 p- U" A9 O 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。: U$ G' z' G0 j k; \/ `# ?! n9 e: m
方式一:
2 Y8 @/ {# @: A6 e1 w6 r 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表, d1 H! \- {1 |+ m- v9 H( A
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和3 ]8 `# |2 a2 G6 [) I
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
+ q" h% x- M" O8 g8 n4 A+ u# Z 方式二:5 S: S* p1 a* L4 e0 `
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:& R* n0 T3 w h; R
SetTitleMatchMode RegEx/ k3 {; V' d `9 j' m4 k9 V
return
* b. x9 S ^5 {4 U7 O4 {" q4 m ; Stuff to do when Windows Explorer is open. r T, {; l+ D( z
;
+ f$ c% B. e M! j* c7 p+ u* ` #IfWinActive ahk_class ExploreWClass|CabinetWClass
+ ^8 x7 E# \* B9 x F; [0 [ ; open ‘cmd’ in the current directory
" m- z" N1 V' M+ U ;. @- c/ |$ N0 M Z9 y
#c::
. z' Z7 \2 x' C! U. ? OpenCmdInCurrent()
, s3 ]' ?* }7 I- a0 O, V' r) i return
0 o0 s$ k: n, h1 Z" \ #IfWinActive' U; j' U+ t* p5 K$ X% A
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
& J) n3 ^& Y ?/ j4 u0 |) K8 } ; Note: expecting to be run when the active window is Explorer.1 h" P4 E1 y/ Y2 W* [. ^1 ^" r
;) `: ?% e7 [( y! O
OpenCmdInCurrent()% d2 g! Q5 Q: c! w: }: M
{6 {( Z) S$ C; ?5 ?0 k# J
; This is required to get the full path of the file from the address bar
* F' W" r$ f$ Y! R! [" `+ U WinGetText, full_path, A
5 b( x+ q8 q8 `+ Z( z ; Split on newline (`n)
' p. u; S7 }; b: j StringSplit, word_array, full_path, `n" g9 k4 y) h) m$ n- i) a8 L
; Take the first element from the array
4 ]4 C* P9 c; S( E+ T h full_path = %word_array1%% @+ `+ Y' w8 E/ j1 x
; strip to bare address1 ]4 ]$ `6 B2 ]8 \ }1 {
full_path := RegExReplace(full_path, “地址: “, “”)
s4 E: G" T, [6 j* w6 v) h6 c% N ; Just in case – remove all carriage returns (`r)
$ J8 i, O( j3 i, o StringReplace, full_path, full_path, `r, , all
2 b: O' n N& C, R. J IfInString full_path, \
0 h8 \6 F9 ?8 I {
7 I( U' E/ q i/ ]% _ Run, cmd /K cd /D “%full_path%”
& H. C2 J) v2 L) f [, {1 W9 w' { }; I6 ]1 C. n/ }% A( z% a9 {9 J
else
+ p) ~8 f5 g' o8 X# _7 o {% U# B2 L" j' [7 E4 `" ^! I3 z
Run, cmd /K cd /D “C:\ ”
$ W7 Y9 F8 Z5 u ] }
$ T d9 o; i* E. P* {% Q7 s6 N }3 y, s" L" ?8 P% H& x9 J/ M) j
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。; ~4 O; a2 x1 p! Z& f4 U) P
这段小代码肯能有两个你需要修改的地方
1 a% m3 f/ n3 e# Z 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键$ B, ?( ~4 X' ~4 W6 W) c
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “; q4 S" Z! J3 w5 H6 L/ O
|