此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
; C- C7 Q& b6 z3 v$ d 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
% f, a& n& d6 p 方式一: K$ h6 N9 S! U5 v6 H9 b
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,, X: N/ ^& Y% N% |
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
" o. e' P) j% U. y HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
! W- v4 x' B6 T; h3 p 方式二:
' ?: x2 `- n, U 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:" F% \' h+ a7 c D# p( G8 }
SetTitleMatchMode RegEx
: X5 }1 c( v% S* F return
3 f' [6 L9 V$ B4 l ; Stuff to do when Windows Explorer is open
8 i. E2 Z0 G3 Y" b8 r( a" C# b% Q( g ;
) S; }$ h" k. E% ?# | #IfWinActive ahk_class ExploreWClass|CabinetWClass
( [* R* |) o& s: E ; open ‘cmd’ in the current directory
+ E& K, S" w! w/ T7 Y8 f ;. B+ v' P1 H0 B7 [4 ]
#c::$ L- y E- g; p8 \% i
OpenCmdInCurrent()
( a7 t% z# N7 J. x Z- n return
' f1 M- d" S% K' [1 }) _ #IfWinActive
; o& _' z8 M9 G ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
$ C( C) K8 p) w ; Note: expecting to be run when the active window is Explorer.
; ]( a! f& k/ A' X1 X5 n ;: M% x8 E' g2 [ V p& Q) d7 a
OpenCmdInCurrent()2 u! y+ p4 v% ?) ?
{! i, N- N6 {/ Y8 o) j
; This is required to get the full path of the file from the address bar
* ]* b5 k. \; e WinGetText, full_path, A
2 r+ H. f5 L U+ K ; Split on newline (`n)# \# ?8 F6 L# Y) P
StringSplit, word_array, full_path, `n- U4 L# p4 Z' i5 B
; Take the first element from the array/ n( p' A- K8 ?+ u& T3 Y
full_path = %word_array1%
5 Q* }: D# ~! Q9 V5 @" P2 } ; strip to bare address
. c7 `# k, I& R1 `# w$ \, V4 T full_path := RegExReplace(full_path, “地址: “, “”)
6 }0 S2 \, `# S+ h ; Just in case – remove all carriage returns (`r). h. `; j" c* |5 C# m
StringReplace, full_path, full_path, `r, , all c8 @$ g$ x$ M+ N$ T/ O
IfInString full_path, \" g5 j6 J; [4 d$ B6 G1 s
{/ E7 c- z* j' I( r) L; R
Run, cmd /K cd /D “%full_path%”
8 S' h6 |# G: \; V }
# U' E- L' ?* T! M else
# ` B' M) g6 W' Q4 M; S {
; g6 R6 D" i; O1 F, h2 D. h. M% ^ Run, cmd /K cd /D “C:\ ”7 v! c0 {6 o, T* M" V, y
}
" C% P2 \6 Y( w. [! d }7 A6 _$ j3 O) O/ K! E. W& r% u5 p
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
; V0 x) a5 J) j8 K 这段小代码肯能有两个你需要修改的地方
3 M2 S' J& k3 A 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键4 S* }( a" G+ Y
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
( u: P2 q0 E& ^- ]% g. z |