此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
- ? L7 r( F" ]2 Q; _- ]' _" G% T' o 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
" U R" Z" O4 a, b- K6 U2 \4 l8 Q 方式一:& o# H7 c' B7 G
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,+ k7 L9 ]) }. @. Y. ^; v8 X
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
$ L- j8 Z/ d- V3 T$ @- j3 L& b' u HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
! r5 @* [0 w1 [, g2 _ 方式二:/ r0 E& R" y& B8 e: v' R( }* g
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
+ f* y `0 ~- Y$ G7 F SetTitleMatchMode RegEx7 T* Z- A3 D% Y8 S7 c+ {
return
) I v; w4 s* Q6 q) W5 k0 X ; Stuff to do when Windows Explorer is open
( `0 l# q% n* l, x4 ] ;* S7 y) M, b& Y: D( G
#IfWinActive ahk_class ExploreWClass|CabinetWClass- i5 c: o( V4 U3 o
; open ‘cmd’ in the current directory
4 F( h/ A& A' @) N+ f b$ t ;2 J# V7 _- J, w& F: ]9 _2 D
#c::
& l0 d/ K7 N5 P: R. B1 U" w OpenCmdInCurrent()
: d% F/ b6 V# Q$ o" N! _ return2 b8 c$ m% H3 q" r) o
#IfWinActive
9 c: G3 {/ ]/ I ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.: B( O1 g& J3 q7 x3 k- h% Y w5 f
; Note: expecting to be run when the active window is Explorer.
6 j, N% S3 c; S7 ^6 l ;9 B( d0 u- O: N* p/ y
OpenCmdInCurrent()% Z9 `: I5 y( O F: Q7 y4 T
{) s. W9 q+ f9 U! J+ Z
; This is required to get the full path of the file from the address bar
3 s' m+ @- t3 F WinGetText, full_path, A1 R5 G6 E% ^6 h7 x+ v! j- N
; Split on newline (`n)
0 L5 A$ T- F( I/ c6 p StringSplit, word_array, full_path, `n; l6 B5 k0 \& G* D5 q
; Take the first element from the array
$ d+ j3 B8 }1 ~+ c) o full_path = %word_array1%
. D P/ z, w# @" i j9 v. D3 u! N ; strip to bare address
% O, U. b, M+ u3 V3 v a5 X full_path := RegExReplace(full_path, “地址: “, “”)
0 x/ ~$ N9 `- |/ p7 f" |1 O ; Just in case – remove all carriage returns (`r): M( i$ e& k) }3 v
StringReplace, full_path, full_path, `r, , all9 H! Y- Y% a Z( z) c$ E* }* ^
IfInString full_path, \; M/ ?+ q& }( q. I
{8 T+ R3 B7 {5 |8 p% z R
Run, cmd /K cd /D “%full_path%”1 I( A1 y# S& k# ?& x" \% \! u A
}# O8 f2 N1 t5 [ }( ]" `2 w
else
* H% q1 n$ m" M$ b. C+ q* {; N% r {& K9 E- u" o# A( r
Run, cmd /K cd /D “C:\ ”
( m9 i" Y& ?7 d4 M% @ }. ?+ m, j& _1 n
}
( d' j+ @* e6 h- k 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
3 l" l) {2 l# v# @! F0 b- b 这段小代码肯能有两个你需要修改的地方' W( c: k$ ^) R$ G
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键3 x9 a1 m. s- Q# a* X: q
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “/ o' A" Z. U* Y! c& P
|