此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
* Y4 t; L2 w3 l; D* ~( \8 @$ U! O 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
1 o3 I. H' |. Q" K& F# W- g 方式一:
. j( e9 S- L% D0 x 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
5 R1 Z% W P8 C+ J5 s& l- q0 B 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和4 Q) g* F, N& D7 f& M6 P& h, r
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
8 `/ b) j' E5 v% `- ^7 a: u 方式二:6 A1 C5 ]. W9 Y6 h
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
- i* Z% F: F, o D( S; g SetTitleMatchMode RegEx
' @) j7 p0 Q7 m; ~5 [* \ return
- m) G+ _% s1 N# @1 r. O i9 w1 D9 S ; Stuff to do when Windows Explorer is open
* V! H- V' q% q& ^1 G% {% @/ v! L8 _ ;% u. i. v7 A! F
#IfWinActive ahk_class ExploreWClass|CabinetWClass( [; d" p8 Z0 k+ w8 P! @
; open ‘cmd’ in the current directory
- G8 n i% x# ? ;
( [$ i5 p$ z+ }- U8 g #c::7 e! L) @4 |/ @# X- P
OpenCmdInCurrent()+ Y4 ~# t9 @7 B6 {
return
: B1 ^0 y# _4 T1 a/ C #IfWinActive& c$ m, b7 `5 l% c# ~% ^1 U
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.* D4 w+ w3 q5 ?8 F/ @
; Note: expecting to be run when the active window is Explorer.
1 \2 ^) v) R* R$ c: q: k( u, ]3 y ;
3 S0 W' S; j; G) E% n* B OpenCmdInCurrent(); @" f) H5 L" }7 j
{
9 @6 h0 N! `" v$ s( n' `. r ; This is required to get the full path of the file from the address bar; _4 J0 X1 t8 v [
WinGetText, full_path, A( `' k: V) R; N% A6 f
; Split on newline (`n) G S* Y2 }5 w/ L
StringSplit, word_array, full_path, `n
( x1 T% n% \3 k" m- Q ; Take the first element from the array8 v5 ?0 O; |4 d, B! j2 C$ K8 \
full_path = %word_array1%% C+ U8 c6 e% `/ U9 _
; strip to bare address3 r* y8 J; t. G+ _
full_path := RegExReplace(full_path, “地址: “, “”)
1 Q( Z7 O; z5 F k8 \ ; Just in case – remove all carriage returns (`r)2 V6 \8 Z8 ~( h( U6 T7 O( j
StringReplace, full_path, full_path, `r, , all
" V! s4 r: B( { IfInString full_path, \1 I: N* Y! n# y& U
{4 A0 z, ]* B. h4 f! g
Run, cmd /K cd /D “%full_path%”; a8 Q" I/ A6 {" {
}5 _* v4 X; V! Z
else) i; U. a# I' \2 h( ?* v. {
{/ d- f7 l( |5 i9 R' z, p* ?
Run, cmd /K cd /D “C:\ ”
& f& t" N" B! S8 l+ g }5 U/ ]" _0 m8 e, c# P6 j
}
& l3 o' D4 N& a: j( I. t 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。( H* ~7 U$ x A A! W- L; i9 y
这段小代码肯能有两个你需要修改的地方
, K% ~7 B! v O9 r3 y5 Y( V 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键5 \: I- c0 z" R1 q
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “. Z, v' `$ U# G7 t2 o
|