此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
) F$ I) b/ c: ^; J/ |6 Z 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。5 p* d2 G2 Y% |6 m
方式一:8 W/ L' i0 u4 \( } A
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,# C' {# l) ]0 R) y
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
" J9 A/ J7 n/ O+ ]. O7 w HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
* t3 P$ }1 r l0 i, I- x+ W7 h 方式二:
/ p2 k H# ]; o" j 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
+ S! g: Z0 ?. [, M4 ?& H SetTitleMatchMode RegEx
9 H- O9 p! A" S4 y; }4 V% G return/ i+ U% k/ Z' [* @
; Stuff to do when Windows Explorer is open
6 E1 a) k' G1 }, h F9 K/ j; e ;' u0 C$ y# m( V7 }, P& d
#IfWinActive ahk_class ExploreWClass|CabinetWClass4 S4 q7 ^+ \: ]0 l* G' O5 g4 [
; open ‘cmd’ in the current directory
7 k. |( Y" v0 p0 w$ k8 r ;
1 _6 Z- ~: X! A1 Y #c::
: t [7 H. N$ ^* E6 N OpenCmdInCurrent()
9 I1 q! d8 L$ b6 D ^) ^; Y return
, s9 ~+ T+ t$ ]& D+ e3 K #IfWinActive( x2 b2 h) @) W3 G
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
& h7 y) |; O+ I' r' {; t ; Note: expecting to be run when the active window is Explorer.4 {7 f( B4 q$ L& ^. p K
;7 E( n! w/ p5 \$ N
OpenCmdInCurrent()
7 I y r! o& X, F; Z# C- U( b9 y {! F* W( q/ q( ~+ N
; This is required to get the full path of the file from the address bar
% |+ @. F" j0 h- l( Q1 G WinGetText, full_path, A
. j0 V, V* u9 P" Z ; Split on newline (`n)
; N; j$ i" N$ \ StringSplit, word_array, full_path, `n
3 I4 ?0 U9 I: @ K9 V4 D' K! j3 K ; Take the first element from the array: e+ R* t. i; |0 O; p
full_path = %word_array1%
! y$ `2 y8 L* L2 n Y ; strip to bare address- R3 y) D0 M s* I4 E, m( i
full_path := RegExReplace(full_path, “地址: “, “”)
/ @7 I; Z c6 P9 D c! c0 V `8 l ; Just in case – remove all carriage returns (`r)
* X5 w/ `1 w+ { d9 S! m StringReplace, full_path, full_path, `r, , all
4 ^ t( K2 v2 S/ K IfInString full_path, \. A" M! I8 n+ k% A+ _
{4 X3 X) Y5 Q7 g' i+ _6 X3 C7 K# U
Run, cmd /K cd /D “%full_path%”
$ \/ b4 P' N8 l- Q }
! O% C# i& R- ]0 H2 U else
' y4 }7 P! k) l) l6 l; Z {5 {4 V0 k; Z }. J+ `. y. o, r
Run, cmd /K cd /D “C:\ ”
% t: h P5 e" }+ B2 @, O }3 F4 C& W- s1 d$ n
}
' g) W" T9 X; a. P8 o9 T 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
7 x1 n4 W [' K! b 这段小代码肯能有两个你需要修改的地方4 ^- a6 S5 D" H4 E+ a& N; c
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
" g; ? l6 `! d! _7 e$ ^, T- B6 v4 d 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
# r, E: |+ H8 N. v1 L5 K: ]' d |