此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
7 X) ~9 {: }/ D: Q2 U. ^# @ 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。. Y) E& c% X3 H% A$ t( R8 r
方式一:
4 ~6 N5 M% b! L, S# c 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,$ U$ l# M3 [4 O; }, }/ P
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
* t Z) p% g4 R) e9 M. \6 I HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。9 ?" o- ?% e6 r: |
方式二:
) R8 _+ q9 R3 e j" b( B E' _ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
' q( o5 L; J( c5 g SetTitleMatchMode RegEx
4 w% ~: d# ~# g, v$ z0 L return$ z9 N. d4 ~! [/ ?! m
; Stuff to do when Windows Explorer is open. i. U: N# m% D' A0 o
;
, a, G" f7 u* w, B" \ #IfWinActive ahk_class ExploreWClass|CabinetWClass
+ w: T2 y1 `- b6 W9 j ; open ‘cmd’ in the current directory8 M8 o3 H3 g7 a2 B+ z" v' X7 d8 i
;& M* H# _0 N. E- I8 f: q
#c::
7 V4 N& m/ |4 ?6 w$ e* r OpenCmdInCurrent()
2 F9 K6 F: ?9 s% ? return5 [. P3 ] y/ ^
#IfWinActive8 S. T7 ` v1 E: U$ D# q
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
( d1 U' ^# I8 _! a ; Note: expecting to be run when the active window is Explorer. P4 ?6 z C" B6 [" F
;+ F4 b! Q5 n1 @, i
OpenCmdInCurrent()! ^; w9 K( u4 @: ~4 ^6 {
{' W+ }8 p$ A6 t6 _
; This is required to get the full path of the file from the address bar% |$ t* |2 T7 Z+ T6 ?
WinGetText, full_path, A* u( y& Z) m& k
; Split on newline (`n)
: w% N% W) D) c; q StringSplit, word_array, full_path, `n
/ M) g' A9 s5 \% z8 C1 W( { ; Take the first element from the array- Y7 g' Y; o) ^! ?* F. V! G
full_path = %word_array1%
/ f: h/ `5 }1 K& ?3 R* {7 v1 U ; strip to bare address/ f" i; M! c; a7 j/ h( t
full_path := RegExReplace(full_path, “地址: “, “”)
5 U1 K; s, P- j ; Just in case – remove all carriage returns (`r)! `7 f6 Y, ]* z/ y
StringReplace, full_path, full_path, `r, , all
" l M. S# I: A/ b( o, m y5 b) O IfInString full_path, \! f/ x5 m- r) V7 v6 {# ]# Y
{! P5 { @9 u8 B7 r
Run, cmd /K cd /D “%full_path%”
$ [" }& Z, [& Z6 e F+ g }6 s5 j" X. l6 [+ C! U. L
else
1 _/ |/ L2 U9 `! H3 Y# c$ r {
% a. a7 A# N+ f; t& w Run, cmd /K cd /D “C:\ ”
$ ?" a1 \( g! u3 N% ~2 N, u# f }5 l* W y b0 Q% T
}; l( {9 D: Y8 B+ @# o4 _
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。3 l" r' Q- u* r" [/ M
这段小代码肯能有两个你需要修改的地方
8 B* G: G+ B- R: {2 m 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
7 q4 |1 ?9 s* I 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
9 U, O; o; n$ _ |