此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
3 z/ k8 T$ f& S! n( l 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
w) \) L/ M0 P/ E 方式一:
9 `, [- M- i# }7 a) s0 ^% c 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
" E8 _2 ]! `% f 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
" O/ v: y) R6 p) P& r4 H/ P% D) L HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。3 i) H: Y3 m% \$ x
方式二:
( g3 {0 }/ ~. p m6 R6 T; v3 u 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
7 U( y0 Q' X" Y" e. B2 [ SetTitleMatchMode RegEx3 O1 G0 u; Q$ c( N0 [+ b6 j, I
return
) M; ~" C2 _5 N ; Stuff to do when Windows Explorer is open' v" v' ^+ }8 ^5 W
;# S- b! i, _) u* |6 v/ u
#IfWinActive ahk_class ExploreWClass|CabinetWClass" [2 [1 a6 t0 ^: @' f
; open ‘cmd’ in the current directory
( _8 J/ `% y4 `0 t ;
& h* _5 w" t7 `3 g( ^% V6 w+ q #c::6 ]9 \* Z9 |) }
OpenCmdInCurrent()
. s) Y, }- K, u2 W4 X0 X return% Q. v1 c5 K8 t$ D+ f* u: r, m0 G
#IfWinActive6 R+ @1 K3 H7 W% K7 h+ [
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
$ P' ^ D' n, Q; ]% W ; Note: expecting to be run when the active window is Explorer.* `+ A/ }/ `5 F% _+ I9 c. [
;$ F* a* m9 q- s
OpenCmdInCurrent()
; ~6 x. a' _! K% ^: m {' [* A3 E/ x/ S: E9 R
; This is required to get the full path of the file from the address bar# M1 B; J, R; T/ |) n0 l* @
WinGetText, full_path, A+ Y: A- {% M! Z0 q; ^
; Split on newline (`n)2 R* H1 s) c# }+ x0 C$ @4 d
StringSplit, word_array, full_path, `n" V2 U; ] }7 g n' }
; Take the first element from the array8 J, k! R( l$ ^9 w, `/ M) T1 V" \
full_path = %word_array1%* h& X- }' ]" }0 m s
; strip to bare address
* s7 g, g1 @$ ]* P/ C full_path := RegExReplace(full_path, “地址: “, “”)
* t, d" U4 }) w ; Just in case – remove all carriage returns (`r)
$ N2 i5 T, Z2 n0 ` StringReplace, full_path, full_path, `r, , all
2 T0 y8 S; H: w! z IfInString full_path, \7 P, \' A. v! e2 T! X, C
{
' w) t9 e9 F& r Run, cmd /K cd /D “%full_path%”
" O; c8 v0 t' m( C }' E, t" a @2 j$ f. g
else
/ Q; E! ~. p6 p, Y {
2 Z3 m. u# |1 T2 j: m Run, cmd /K cd /D “C:\ ”
) e; ~. I- f0 R% J: r5 f' D6 R }. U8 C$ H3 t+ }* y
}' b( y: f0 w* T/ q
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
, S7 Z8 u9 a Y; L: Z/ j8 I 这段小代码肯能有两个你需要修改的地方
. A: f5 ~/ Q, t 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键3 e8 i0 Q$ w9 L+ v: G. i" g
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “6 D. t9 T) g0 e4 T$ ?
|