此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。# l8 o1 N a0 ~! D2 W4 ~, [; ?
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
( N. O- E4 S, ^ 方式一:' n" N* G9 U$ {, ~" H3 y+ J
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,$ n1 B9 n; i4 K0 |3 ?
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
3 u% S( p, E8 Q6 k+ D: o" b HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
3 ]7 U( C9 S1 g! ?3 S* M, o 方式二:
/ C; o7 L5 ~' U 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:2 F9 F2 b4 F/ L# H
SetTitleMatchMode RegEx
: u; a) ]0 u" l return
7 B4 Z2 F9 p) `% b2 g E5 q) S ; Stuff to do when Windows Explorer is open
# k5 Y9 C% T( F. } w ;- e" `4 X- u' B/ |. t* j5 p
#IfWinActive ahk_class ExploreWClass|CabinetWClass1 ^8 G" n& a$ F3 B
; open ‘cmd’ in the current directory' f$ ^4 ?5 B! X2 g8 }$ l; Y: ~8 ]
;
2 F1 S p' A" d7 Z #c::$ Z7 c) g: ?8 n( I1 G
OpenCmdInCurrent()
5 ] J) S6 V8 n, u return1 ~+ I6 Y) Z, `0 q
#IfWinActive
- o9 D) {. a/ ]8 U. T9 c9 \1 ` ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.+ p% c- B. a8 O
; Note: expecting to be run when the active window is Explorer.
6 b+ h3 \6 q+ f4 V- }2 I: U( L ;
9 p' K- ?; S1 g5 _+ z( ~ OpenCmdInCurrent()( ~3 Z5 u1 Z/ q$ s
{
) L+ x% s& N+ f& c; I ; This is required to get the full path of the file from the address bar
0 n, w$ i; R4 z. v+ a WinGetText, full_path, A
% v, I/ N2 M9 p ; Split on newline (`n)
. s8 d8 k x6 u% ^ StringSplit, word_array, full_path, `n
, ~: F. _: Y5 W% o+ @ ; Take the first element from the array% q* Z* p0 E# R# k5 d% q
full_path = %word_array1%
8 K, g9 j7 v1 c# K& a ; strip to bare address
z+ Y4 ?/ m7 w) I% l7 @! P( E; z, q full_path := RegExReplace(full_path, “地址: “, “”)
& ~; t2 P ^+ \- S0 [# V9 [ ; Just in case – remove all carriage returns (`r)0 b+ w$ K1 _( M
StringReplace, full_path, full_path, `r, , all {$ Q9 J# w/ b; \! o% t$ E; w+ {
IfInString full_path, \
; X, ?. J" H, V; q- F% S5 D; H {
5 k/ e% i5 a" x( N5 ]( K; s$ w Run, cmd /K cd /D “%full_path%”
; w2 s7 {3 _% l9 q$ m. E4 c* [+ d }9 _! X$ ~2 i2 H
else
" B& d# l" U8 x" s8 Y* O4 C {# F7 C. _2 f0 ]6 t7 y" {
Run, cmd /K cd /D “C:\ ”3 y8 @9 g) k) p4 o- s3 v
}
" T& f( Q2 W8 X Z/ b# a }
! S/ W5 m# t/ k8 t7 C8 V 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
6 g5 A) L& O) e7 b# V B, A! q$ C4 E 这段小代码肯能有两个你需要修改的地方
% E( X( t& J; ^# g! ^0 ]8 M 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
9 g% ^ Q7 d" g! {3 I 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
8 O, ]' c6 M' z0 t |