此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。 X ]! |. F2 @9 H0 S" n
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。! Y" O3 N7 F5 @2 E2 x5 [
方式一:
/ e5 u3 r# ?7 n: Y! C) i 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
z6 @% h' Z( |" z; t) n" w1 o 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和2 M2 R) A% F4 T0 Z- C; ]% h
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。6 S) I% V) s+ e, t, s$ }
方式二:
* o3 Y8 d8 U9 d. k) r 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:/ ]# P0 t d1 n6 G. D6 J
SetTitleMatchMode RegEx8 u" J4 z) Y* j, R
return8 i" ~- N! G+ U
; Stuff to do when Windows Explorer is open- J j! `. w( f! }1 b/ ]: L
;
1 T' i% X' c; M, X/ d- Y #IfWinActive ahk_class ExploreWClass|CabinetWClass9 U% `8 x/ p+ z. t0 p3 i7 v
; open ‘cmd’ in the current directory
y6 |$ j: R4 ]- B& f ;
5 @( a' A; k/ @7 E$ C: @$ q #c::
1 }! N+ L+ @# a, h7 p5 ] OpenCmdInCurrent()
7 Z9 S1 `2 R4 n8 [$ e! @9 q return
) X0 Y6 |' b' m! @' k X #IfWinActive
+ k; E% t8 K; a; O$ N" j ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.( f6 r4 K; g9 V5 i; X" {
; Note: expecting to be run when the active window is Explorer.6 q- [+ N% y% G! F: m
;3 i: l" b, j5 l: F" v+ |: }) Q
OpenCmdInCurrent()2 y K0 ^3 V2 W% L
{& t: S0 i8 d2 ]( \' e1 V
; This is required to get the full path of the file from the address bar
7 G# J2 O7 G) B' Z- N WinGetText, full_path, A
7 s9 L+ m+ M+ H1 o3 e ; Split on newline (`n)" \7 t* a: x7 I3 |
StringSplit, word_array, full_path, `n
8 B: w4 m: R2 ^: m ; Take the first element from the array
2 b* g2 I% ?! L6 q! ` full_path = %word_array1%
* o9 z, b# N2 P ; strip to bare address
* O h; j! X0 X' N full_path := RegExReplace(full_path, “地址: “, “”)
y v0 Y: w4 y- D: c ; Just in case – remove all carriage returns (`r)* Z U1 P) P) m) a
StringReplace, full_path, full_path, `r, , all% D5 D1 i2 B" g& o$ D% G3 g
IfInString full_path, \. N0 {! v9 L' b9 V( m
{+ }; y% _/ [! S% G- x' h0 q
Run, cmd /K cd /D “%full_path%”
$ m) m5 [) | {. m8 a$ F }
3 d. ^0 e' T% C( { else
" Q7 Y1 B' N0 a) C! e: g( A! S {
0 n) | p/ Y/ i2 c" B- { [- l! b1 q Run, cmd /K cd /D “C:\ ”
5 r) P! L- q9 _& v- } }" T* ?: ~# W1 e4 j, \! T
}
$ A, j1 l* h! @6 X: Q* B; p9 x 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。) X& c! R& [7 N+ R6 L% W2 s' t
这段小代码肯能有两个你需要修改的地方
( |1 V0 \# v8 `2 W( C+ w 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
. ]9 d; ]" T+ Q3 ^7 n, O# @ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “9 o! O9 E) W. E: P
|