此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
% q/ X2 m$ M4 r6 v" l" n: | 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
$ f5 ]9 z2 h' B- a! X$ ?4 }/ _7 i 方式一:
) T5 t% h2 J/ M- r6 n( O+ E 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
) m* O- g7 U& o. ?0 \0 X: H 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
! B* q. D3 y9 M. d HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
5 s$ X" B- n6 j5 B 方式二:
2 I3 U5 ]7 D- x, _ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:$ f. e4 N3 ~# k7 K, S
SetTitleMatchMode RegEx
+ C! H+ L& n3 @" ?# f: m return$ q; u* ]; N# J7 n8 ^) o; n3 ^
; Stuff to do when Windows Explorer is open
6 A0 z. [8 o* _9 ?0 Q0 c) @ ;
* I$ v6 j& D5 n& \' q) E; D #IfWinActive ahk_class ExploreWClass|CabinetWClass
. g* M7 a& E' r) y* e ; open ‘cmd’ in the current directory
7 Q7 C9 v- `) L ;
, U: R& d2 y& n) y% t- W$ ~ #c::
9 L$ ~3 f* w5 I) B8 J5 I o& g OpenCmdInCurrent()
* d3 I9 f' O/ A+ N return
) v0 c E- s/ T, q& D, f7 i #IfWinActive
( [" U" D" h( b) ?% a4 L ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
* f) d) R( n4 Y; F ; Note: expecting to be run when the active window is Explorer.
3 w3 q8 r9 o3 _1 l [4 x0 d ;. \4 R7 L. J+ P6 ~2 x2 O* D
OpenCmdInCurrent()) `9 ^# }/ K/ O3 f3 D- r# u3 O
{ i# i5 u, r8 ~
; This is required to get the full path of the file from the address bar, i0 o) `' Q" V+ M. h6 C. m$ B
WinGetText, full_path, A
" i& Z( D- d( g ; Split on newline (`n)0 s" k0 O1 t8 V1 S
StringSplit, word_array, full_path, `n
# n5 r$ w5 T9 A5 S N& L% T1 v ; Take the first element from the array
% [! }/ ^7 C! v! o0 ~ full_path = %word_array1%
, K2 w9 t. A% f, q Z- D4 m8 V5 V ; strip to bare address8 _0 k0 N& F* \* K0 [6 ], V
full_path := RegExReplace(full_path, “地址: “, “”)
7 s0 T* O" s; ~6 Y ; Just in case – remove all carriage returns (`r)1 H. J: u) \1 x- N7 G1 S- v$ o* a: Y1 `
StringReplace, full_path, full_path, `r, , all) z5 [# e7 V7 S1 d# j
IfInString full_path, \
_5 c, s5 ~3 ]* e {
$ W# F: a4 \4 f0 S$ z9 \ Run, cmd /K cd /D “%full_path%”5 L# ^. H r! {$ s$ U2 V6 E/ J
}
" x' }) i* C; ^$ M: ] else8 l/ h- P. V, K) x" O5 \' P
{
7 l/ R- e9 ~# R! q Run, cmd /K cd /D “C:\ ”
5 O0 m0 f* o3 E3 z( D2 N }
) O# {8 ?7 {; H e3 t }
! b6 o% L" ~" W7 | 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
. @8 s2 o5 s9 g# T9 C 这段小代码肯能有两个你需要修改的地方1 J5 T; e5 m# k- H% ^4 t; I
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
" {1 C( s% J: Q, ` 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
8 g- w7 h4 w& u |