此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
6 Z& m9 i' E3 q* o% E( L3 l 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。4 |3 L) Z# |7 v- @
方式一:$ D! J6 N) l2 f6 K" K1 ]* Q ?
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,, E& T% {4 L" ~# ]
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
6 ]% e' P/ ]) F5 l HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。! ?6 L- g3 D7 E$ u2 ]3 N, i3 k
方式二:! H# V% A; r" b; u5 `0 T
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
3 O( c& \" j' s) S2 ] SetTitleMatchMode RegEx
! e$ G# l. a F0 ^ return" l$ ?. N4 o) H/ q8 K" Q* ?
; Stuff to do when Windows Explorer is open
4 @( B% s: k: T5 w ;
, v- v t: S# L l+ j7 _+ ~4 m* o #IfWinActive ahk_class ExploreWClass|CabinetWClass
6 o; ?' a: e$ \6 a% a) R: n ; open ‘cmd’ in the current directory
: Z6 I! r& i+ B, Z ;$ D6 Q) `' d0 E) D. E
#c::$ \' C6 Q9 y: {; E* D$ M
OpenCmdInCurrent()
' n9 n6 n3 g; A& E return
[9 z, \2 X+ N5 t# i( a. u #IfWinActive
1 T2 L3 q0 E( ~" Z9 l2 m ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
" S3 ~9 W1 T7 z$ Q ; Note: expecting to be run when the active window is Explorer.6 A( Q" B6 y: s Z+ s
;6 ?& b }8 c! Y) N8 Y
OpenCmdInCurrent()
+ X: U- U4 N; _& F" s- E+ p {6 j" u6 o% s( P" m( k
; This is required to get the full path of the file from the address bar
' y+ [" Y# [( R6 N$ |: Z WinGetText, full_path, A& S( e# F: S: H u
; Split on newline (`n): Y; m# f' T4 y7 q; H) R
StringSplit, word_array, full_path, `n
! Q+ |1 l0 |: M ; Take the first element from the array
. Z1 e$ B: m; @: {& _ full_path = %word_array1%
U4 M, G, N3 O% S B" h: k ; strip to bare address5 C! y8 W+ {2 e0 ?8 ]$ k i
full_path := RegExReplace(full_path, “地址: “, “”)# @9 Q/ X, n* s) k2 W6 h2 \1 w9 V
; Just in case – remove all carriage returns (`r)
. m! \0 h) M5 I1 U StringReplace, full_path, full_path, `r, , all; J7 l# X( F' ~6 |+ B% b6 p) Z: ^- u# `
IfInString full_path, \0 V# N" i9 B& t7 p( R D
{
4 Z% D5 h+ J }; j( }% ^ Run, cmd /K cd /D “%full_path%”
4 @9 p9 O% i2 D/ P( l/ w } d8 T+ O* o5 d: j# B+ V$ z
else
+ y4 U7 K7 j6 ~1 M {
& S7 L% r1 n! ~& C8 e Run, cmd /K cd /D “C:\ ”5 q# B4 P& v, x2 U: B4 }8 {
}
6 S$ P% P4 \" Y+ d* ^- [ }8 o- O: I2 b0 x, ^! v$ a( O$ z
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。4 L: M7 Y# X6 [5 F/ Y; v9 T
这段小代码肯能有两个你需要修改的地方5 a7 b; E/ | P' W, ?3 k) B9 M
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
A4 x* }: E+ z3 I 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
9 X7 ]) p9 V. i$ D, ]* Z9 u |