此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
. H5 N3 @( u+ t' V8 {! |3 G2 ? 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
4 q$ t; C7 t1 F( d+ _4 W 方式一:
, e& p! N1 {0 A$ H2 K 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
9 i6 f/ f9 ^& s7 U# z+ T5 S 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和; ?% f) p0 W$ y
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
7 O& m. `9 e8 T3 i: `% [ 方式二:
7 F2 i; h% k2 b; c7 y 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:3 z' _, L: o3 Y# I; R
SetTitleMatchMode RegEx& A8 y) K8 `' ?, H
return
" _8 X4 ^( j- k g ; Stuff to do when Windows Explorer is open v" j- s/ g2 c# G1 C" A( b
;4 |/ R* x: t) G; S4 E$ n" i- }0 z
#IfWinActive ahk_class ExploreWClass|CabinetWClass& c/ T2 h: o0 F! X4 K8 Q( W5 @5 Z" W
; open ‘cmd’ in the current directory
5 W+ L; u& g% h( v0 d# A+ { ;5 o$ e$ R8 o4 M8 P- q
#c::+ A; p# Q3 T" ^
OpenCmdInCurrent()
/ W' k5 Z6 c* K; T. n return
+ P( \; |; [+ h: u5 ]: p #IfWinActive% W4 z& v, d# |2 r) r' [
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
( O% x% z2 k! X3 J/ }1 T ; Note: expecting to be run when the active window is Explorer.0 R/ O* ?" U2 D3 x* Y$ U
;
7 J) m: E L5 _* p! a) X V5 k0 I OpenCmdInCurrent()' O5 o1 }1 l* [6 z* |
{+ A0 U0 _5 M- Y2 e, x. ?; U5 P
; This is required to get the full path of the file from the address bar
. ]4 o' \$ ~" U, [ WinGetText, full_path, A: x2 Y( }: V; x) @
; Split on newline (`n)
, v" O; s" m6 @ StringSplit, word_array, full_path, `n
/ q1 J7 p0 ]0 r ; Take the first element from the array
0 T. O0 |- k" {/ w/ W full_path = %word_array1%
5 J0 }# p' A9 o4 a ; strip to bare address$ q3 M# Q, L6 b" l4 _
full_path := RegExReplace(full_path, “地址: “, “”)
# I' W* [) G$ G# G, z* D O ; Just in case – remove all carriage returns (`r)
/ f+ b' }! ~' Z StringReplace, full_path, full_path, `r, , all
- u; r$ J' g( V \0 d0 @ IfInString full_path, \# T+ M, L6 S9 m2 _
{* G" a' G' l9 S2 c" \
Run, cmd /K cd /D “%full_path%”
. m0 T ~1 j/ m+ M }: m5 _+ y8 R* f; q0 W' B1 |
else
( i6 }" A, C0 _" T: b+ N& b" m {! P4 g& r% Q/ Y7 G# @
Run, cmd /K cd /D “C:\ ”
( u* q( \' ]7 ^; P; f' [7 o2 s }
& @; U6 n$ L' [1 P4 ] }. A9 Y( o& d1 e" G3 {
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。' D, H u1 f( |6 [. e0 t( m* @
这段小代码肯能有两个你需要修改的地方, k" X- F# l8 i6 ?$ D! Z
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
& y% ~. M8 z! F5 e3 q) C& V 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
9 c& H4 ]1 Y1 m9 { |