此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。" d7 Z8 E+ ?/ O5 f+ P- Z& Y
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。 ?& E8 n6 [: ]) p# k- s3 u
方式一:: L# v, l9 C+ J2 W
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,2 V7 J+ ^9 ?% g) h: G* B
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和0 u$ E+ s; E) O; j. }
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
( [$ c- U4 \0 c8 P9 C" _, Q. } 方式二:+ ?. `3 t' b8 f/ l. o3 [3 C" S
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
8 M; e0 V- M5 s* i SetTitleMatchMode RegEx
! P$ d9 X3 b5 j7 y) t% Y return$ J0 v' Y, l0 ^' @. T- R
; Stuff to do when Windows Explorer is open
/ s) ]0 h- O0 g8 D ;9 j/ n& t" W Z& q- Y
#IfWinActive ahk_class ExploreWClass|CabinetWClass
% e0 m& O$ M6 x) T6 q ; open ‘cmd’ in the current directory, n9 A. g: w" P: }( n
;; x3 b# M' B' \7 G7 K$ r
#c::
$ n) i- R0 G: X2 `1 i OpenCmdInCurrent()- p/ @( `+ U6 H: Q+ J
return3 H# b: \2 L! B. {( ^' G" W' F
#IfWinActive
" k! Y7 g- r( q+ \. }$ n3 y5 S, j ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.: @& n- o% s5 }* _. n
; Note: expecting to be run when the active window is Explorer.2 N* x! U) Y- K' M( h- v" k
;# \6 |* m( ~; A* X
OpenCmdInCurrent()
) E7 o4 Z9 n; _! T {
1 g- C& ~4 G* v7 H+ E! W1 n8 K ; This is required to get the full path of the file from the address bar
7 Q8 c A9 i& U/ Z WinGetText, full_path, A
* K6 |& Y* G5 A" z ; Split on newline (`n)! m" G7 l$ u- S
StringSplit, word_array, full_path, `n
" E) ?0 j* j. |& c3 l5 R0 W7 p' R! p9 u ; Take the first element from the array
. K; v; `! x9 L$ w full_path = %word_array1%
! L: B' }; n0 P* K# l( \+ ` ; strip to bare address
3 z/ X! T9 b% U X full_path := RegExReplace(full_path, “地址: “, “”)
9 n7 c) K+ v9 |% m6 q. ~' R- H ; Just in case – remove all carriage returns (`r)7 q* m1 }- Z; ^+ j8 X0 [8 V( e, D
StringReplace, full_path, full_path, `r, , all* Y5 e: W3 N' D6 A4 M+ J) H6 v
IfInString full_path, \
& W, Z* ?5 X( q y {
8 @, e# P; l$ H! u2 C Run, cmd /K cd /D “%full_path%”" ?9 |8 [7 q! ^7 L3 {
}
) P# ^+ r% i, k) Q* z( S else$ o: h/ j: H3 E3 [# z9 n5 ?1 s
{
$ Y/ g3 T3 V" e$ n V3 ^0 Z. n Run, cmd /K cd /D “C:\ ”
4 A' _8 e, z0 a% W: [/ K. k. X% B }' ^" w1 F+ B7 `, ` _. j0 X
}
e6 L- ]% E( J- L) ? 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
3 A- B E6 X: V7 ]: F 这段小代码肯能有两个你需要修改的地方8 x( T5 P% `$ o8 Y/ ]* o
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键& [$ r: w* c7 I" \2 ?
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
7 x( A& |; R* l* D# X! U4 U |