此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
3 m. L' v: J0 j5 E1 B4 t' ~1 k 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
. g# C7 ~$ h0 X* ^ 方式一:
: ]; d, Y: y- ]+ N( ~ x' L 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
& \+ W# |2 J5 T 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
" V0 j) w2 i! ^( i- N9 V- n HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。# S4 O' T- I+ H
方式二:
' ?6 @- j! l: _: j9 \/ | 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
: X- F3 f+ m$ |8 t& _: C! ` SetTitleMatchMode RegEx5 R# Z% p; X# K9 t O& T% G
return
6 ]& a8 S$ k( `$ E6 K) @- v ; Stuff to do when Windows Explorer is open& \# O! R2 [& Q2 f8 d# `
;3 z/ C# } H9 D
#IfWinActive ahk_class ExploreWClass|CabinetWClass
7 {) V6 m0 R, G6 @. z' b, ] ; open ‘cmd’ in the current directory
8 A4 K M+ R& v2 q ;1 f: [- T9 a- h5 |4 f) D
#c::. m7 K6 |/ l1 d" Q* i% w
OpenCmdInCurrent()
' j: @" w( f1 _9 Z return
; d9 N) ^ {/ ?# |+ L #IfWinActive
* S! g$ P2 B. D7 }( N ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
- E/ Y% G( t: ^, Z0 Z5 L9 C+ N7 _. z ; Note: expecting to be run when the active window is Explorer.' n4 L4 A5 m5 b9 `& X* p- c) F
;8 _) ?' n2 P) {0 k, R3 H
OpenCmdInCurrent()
: ?1 n$ S5 S% }. o, T9 m {3 Z! e' k& d# b6 h% o1 n7 F, @
; This is required to get the full path of the file from the address bar
0 j5 r% _# p9 K1 W! v5 J+ [ WinGetText, full_path, A
( J2 C- c# w+ A7 U ; Split on newline (`n)
+ b7 G+ V& _0 V+ U4 \ X StringSplit, word_array, full_path, `n5 i( v \7 W$ M0 S: b& O
; Take the first element from the array
+ {, K) [2 u9 ]0 g full_path = %word_array1%: |- p, H$ O/ h- h
; strip to bare address0 y. ^. a+ S. p. H! i" I) _
full_path := RegExReplace(full_path, “地址: “, “”)2 E- A+ N: Z& a I N
; Just in case – remove all carriage returns (`r)' l4 Q+ G9 p5 @6 O N
StringReplace, full_path, full_path, `r, , all
& [- Q) s; C+ n# J+ Y2 E7 V IfInString full_path, \7 n2 W7 k4 D3 u$ R
{/ W# u7 N2 e5 ^* r' w6 ^7 n
Run, cmd /K cd /D “%full_path%”
( D. ^7 n0 v, e5 G0 c: Z- j0 S }$ w) Z$ Y5 ~- r6 V
else
* h5 f+ h0 {% A) F) W+ V {$ a k& Z: y% k
Run, cmd /K cd /D “C:\ ”+ w& I0 y( x7 ?0 I; j d/ e
}
- {( d0 I& D2 \, M }& n& J0 e" Y" W6 f* C" x& W
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
0 w& e6 \( n7 J+ x* R# v5 U. } 这段小代码肯能有两个你需要修改的地方. t4 y1 R. o: {9 |* e* I" `
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
: v4 J( E; _* W 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “$ I4 K5 p, v1 n+ V% r
|