此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。 j# z1 [+ ]7 E' K/ S' c. c
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
: t0 X4 b! D" J& n) {( H O! q 方式一:, ?, k: r5 F+ V; _4 n* p
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
, k6 ]* N: @9 h+ ]" @+ f 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
0 N; w3 {1 ~7 f3 k1 z7 M HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。4 g0 u# K5 I: t
方式二:
5 t: X7 Z: U, W; e& _ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:/ f) {5 b3 w% t& a
SetTitleMatchMode RegEx
3 H. N" D3 R: ~( w return" G. W, s7 u3 z+ P2 y; y
; Stuff to do when Windows Explorer is open
, v- ?6 {; B7 ?# j ;( F& E( B. K! | k; A
#IfWinActive ahk_class ExploreWClass|CabinetWClass) P# h: a: H' W
; open ‘cmd’ in the current directory
4 b; `& E; o% C% k/ f ;; G2 N! [5 o9 A
#c::. P- K; B% S) K: C1 t Q, G E
OpenCmdInCurrent()
- F2 A! H. P/ W: o: S( |2 Q% m return# {+ F& W' Z# u' N' ]4 M" C
#IfWinActive, |- J1 s9 ]5 T* ^& l+ C
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.- ^# l* e6 ]2 o
; Note: expecting to be run when the active window is Explorer.
6 q3 l6 [1 A5 L* A ;
8 B8 Z- |+ U( D/ _/ V+ } OpenCmdInCurrent()! v& y @% y- l0 ?
{
7 m# z" |8 t( k" P8 {6 D6 H- O ; This is required to get the full path of the file from the address bar z8 G. ~% ~+ G- `
WinGetText, full_path, A
5 J0 f, ]3 ]; {0 @9 A2 g ; Split on newline (`n)
$ A* z4 Q6 J$ |& \: l" H2 x StringSplit, word_array, full_path, `n
/ T' H) W, G* k$ y) w( x4 i9 W( c ; Take the first element from the array, D1 `7 L( w: ]2 Q! P7 }* g, \
full_path = %word_array1%- O8 _: f2 ^% h
; strip to bare address" G1 {* u; s% f$ y+ w
full_path := RegExReplace(full_path, “地址: “, “”)
% B" |, `! e# q6 p( ^" ~ ; Just in case – remove all carriage returns (`r); n7 m2 e( F. H5 O/ R5 A
StringReplace, full_path, full_path, `r, , all
( {6 q3 ]% t6 ~; M! C9 V# j IfInString full_path, \- ?1 C% X) L) R: u$ i
{
$ S6 P, b2 |& `9 f. L3 R: T3 E { Run, cmd /K cd /D “%full_path%”
- ~; o8 e2 D& V$ B } Y3 [1 h) ?0 Q: X2 i; M
else3 y, _2 f/ x( |. d _
{
0 @5 S. N" G2 x- u" n" E" q4 S$ H6 |0 _ Run, cmd /K cd /D “C:\ ”
+ v5 n2 o$ ^4 _" u, A }
+ b2 `; V+ Y! \9 n% D- l }
5 A, [( B8 ]3 I4 @ b 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。. l$ i2 r0 a# `5 o, P& j& A
这段小代码肯能有两个你需要修改的地方7 W/ U8 c) ^( o1 E
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
' S% f- i3 W: m; [ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
+ ` T) @/ T6 O! b |