此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
0 ~: d7 f, G! Z4 Q9 y 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。" `$ _: I- ^+ c5 r2 E
方式一:
* K% M! j) U5 r7 d1 p$ E/ v$ X c1 p 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,0 o1 l! q9 `) C) a9 q
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和/ L& n( A* O; o2 H% d; I
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。) G' c2 N0 W/ f2 p9 W; X2 ~2 Z+ ` N
方式二:
5 ~( i* [5 ]3 u" l* L. H 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
1 [( D2 C- Z1 R' ]: l3 { SetTitleMatchMode RegEx+ a- P# W, w$ [ V
return+ I, ~2 q. P. m; u, k: Q8 J
; Stuff to do when Windows Explorer is open) Q# e" T! K8 `% W+ v) \* o6 o. n
;
% L7 ^, `! o. F7 i! L4 u7 F #IfWinActive ahk_class ExploreWClass|CabinetWClass
! u+ q" |2 _9 Q& f ; open ‘cmd’ in the current directory
$ b6 I1 o' C, x _! e ;
/ {- ?& J5 Q+ r9 K. ` #c::
& p0 Z4 ^& F; I5 E- C0 r$ Y+ P OpenCmdInCurrent()
+ {% g- E1 D3 s! C return) H# Q* B4 ?+ t w
#IfWinActive5 _3 C5 m0 B0 k
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.1 a; y( r; ^% S. D0 y& C& G+ J
; Note: expecting to be run when the active window is Explorer.3 q1 l+ W6 ]. `3 W9 I* S' @
;
( ~+ p: j* B6 v OpenCmdInCurrent()
% k- \: H" B! D! _6 ?+ a' C8 P {3 y2 D6 ?/ C4 o% x1 z+ [
; This is required to get the full path of the file from the address bar, K: N& P, p0 \5 N' E- J+ V4 [
WinGetText, full_path, A9 z# a- t9 f: ]& M9 a: B& P* P$ t# @7 p
; Split on newline (`n)& p# k7 \7 e$ W/ m" y K& @
StringSplit, word_array, full_path, `n5 ]5 f, A7 ^# J5 D h
; Take the first element from the array! D* l- M" `# T, ^0 l2 ^
full_path = %word_array1%+ H' x+ W6 Z% ~$ J( ]6 H5 C/ n
; strip to bare address
+ m3 Y. M7 a0 k! X# |' u" k full_path := RegExReplace(full_path, “地址: “, “”)2 e% q" [# B. c; k. W! r& d! i
; Just in case – remove all carriage returns (`r)9 W; g1 _1 W6 c% y. @6 q
StringReplace, full_path, full_path, `r, , all2 Q3 y( j( c9 F6 s, O+ h: `
IfInString full_path, \- v0 d; j( s1 z! v# _( u$ R6 Q
{
# _, G+ K# r7 u Run, cmd /K cd /D “%full_path%”1 i7 T9 Y: B) P. z: D
}
- C6 I' D! d( L G! Y else
/ x1 D! Y1 g( ?/ c; Q' p# E {
* y5 A6 y# _% v% c" Y7 i. ^' x Run, cmd /K cd /D “C:\ ”7 d% `4 _. v2 K: }) m7 _# h! }
}# u! I r$ c/ U" i& \
}" F& B/ T$ [0 } U' [" d8 Q1 z
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。, E' e5 j% [8 r/ Z+ X
这段小代码肯能有两个你需要修改的地方
. a' }* s2 i3 S/ p! `! K& O 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键1 U& H7 X& `. M- M' Y6 E
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
" P" l N! A9 v6 I |