此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
% Q4 u8 o* H1 }: e, A; G' ] 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。0 z" i4 J, y [3 q* ~( I
方式一:
3 | c1 z0 S4 u2 C) z$ `# r- a 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
, ~9 ] |" c% [" T 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
4 D6 M1 E( M$ Z( m8 E$ s HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。) I7 d) ]4 P8 ~0 Q3 h& w
方式二:* t* _. ?( F: I; x- ?# e6 \3 {
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
" `- u6 `+ @5 X& A/ n SetTitleMatchMode RegEx/ {' [; E0 r' |8 \- o# A
return; L, } ^# o1 F5 W$ O
; Stuff to do when Windows Explorer is open1 L) _' j# U$ j; e; k
;
% u, m% R7 [( A/ @# s8 Y3 X #IfWinActive ahk_class ExploreWClass|CabinetWClass+ i9 O6 J4 P, L3 [" `& x
; open ‘cmd’ in the current directory
$ |& r$ Y) B% t ;, P9 j6 Y8 C. i/ M" T8 o* ?# I& [
#c::
! b3 L) `3 `. ~5 f OpenCmdInCurrent()* t, |& P( G' N5 n8 s7 P2 x3 l
return
# L: s: F, W( l; T) Q1 f" Z #IfWinActive9 d' w. F% k) T [( U/ T
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
5 Y( D, D7 w9 s% i/ U# l; p$ j ; Note: expecting to be run when the active window is Explorer.- d' B3 s3 s/ _- }
;
' J" ^' }" E8 ~ OpenCmdInCurrent()' G6 c9 w, t- a( n- I+ l
{- t5 V( ^; W5 m2 ^* s1 b
; This is required to get the full path of the file from the address bar
# u0 {: D5 Y( r* i WinGetText, full_path, A
6 {2 d" o$ u0 Z ; Split on newline (`n)' W0 K+ Y0 Z6 V$ o( l7 {
StringSplit, word_array, full_path, `n, O. a/ c$ @, `- y: ^; z, W# g' i% e
; Take the first element from the array
2 d5 f0 z& `! ~6 `/ w% J full_path = %word_array1%' [6 u- a; F/ x8 d1 ~
; strip to bare address
# O3 u3 _% k/ w7 h+ p full_path := RegExReplace(full_path, “地址: “, “”)
, F" F) R2 i9 y. F# o ; Just in case – remove all carriage returns (`r)
! A2 {8 k D/ t! n% N, r StringReplace, full_path, full_path, `r, , all
7 T: V% X9 u2 x! J+ Q' h IfInString full_path, \% k, @5 W1 p! n7 `5 R- Q9 `
{
8 P* E- X! m; G* H9 K1 l Run, cmd /K cd /D “%full_path%”9 X2 k: v/ G5 T5 h8 i
}' Y3 q2 F. e; Y" L
else" h! r$ s- j1 ^2 O `' J- w
{
3 I# H( ?- b7 W3 n Run, cmd /K cd /D “C:\ ”
, u# s: z! ~5 o- _( J$ T }
% Y& ?1 ]! x1 D }
8 Q7 i9 f+ ?' V9 c; u! d9 d5 W0 Q" g 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。0 t! w" |8 p* \! w4 |1 c
这段小代码肯能有两个你需要修改的地方
/ B7 n/ ^- V( i 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键( v- b' f7 O$ w" R+ Y
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “3 r7 T7 @- F4 d9 s' [6 O( O, T
|