此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。, @$ k$ c! a3 }) m
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
0 f- u' w- F1 G* E; q9 e 方式一:
& v6 o; Z! W7 a+ z; Z, L! j1 O 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,2 _- J9 n2 i0 ~* _/ s% M- W* \
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
' A5 n9 x$ B1 g* C HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。/ S! X- W! R8 h+ N9 [- \
方式二:
; Y: i/ S8 T: J 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:- L' i. D$ |! H' e& S; {' N
SetTitleMatchMode RegEx
3 |* _: @* W! w; _, g return; S) i+ M( z, d' U5 M8 U: E; i. ~
; Stuff to do when Windows Explorer is open
% Y# ~5 e7 X/ ^/ @. T( k; }, X9 C ;
% O# z. {1 M& a4 {, p9 s& _ #IfWinActive ahk_class ExploreWClass|CabinetWClass
& ?: h" R* A R6 G$ ~# F( O ; open ‘cmd’ in the current directory
. W6 l( {8 V, M: r& A, L ;
# S2 |: x t0 O0 t: |; P Q #c::
* k- N( F; s( t3 { OpenCmdInCurrent()
. q, k4 U# w6 l( T- M3 R return9 A1 F/ ?' `+ G% [
#IfWinActive! c: e: q; r% R* {. k
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
' f; L# c$ r0 g; F ; Note: expecting to be run when the active window is Explorer.9 G _8 \" D7 C7 u+ B
;6 w' Y: W2 r8 R6 ?+ u0 Z; Z7 @
OpenCmdInCurrent()0 I4 t) F! U' G0 ?& v4 n/ ~% V# ]1 @
{! ^3 e' G* F# Q* F$ Y4 N, r
; This is required to get the full path of the file from the address bar
8 R2 Q1 u/ D# p" m$ ?) G$ v O WinGetText, full_path, A/ T. l) A( c9 H; s1 a8 ^* R
; Split on newline (`n)
P1 |( B! @3 f4 r7 A0 A StringSplit, word_array, full_path, `n
! b4 y0 s# D) A6 J' _ ; Take the first element from the array
/ @! L' z" R1 }* g7 n( h) f0 u full_path = %word_array1%; [- [8 d, y) W# U1 P5 g! ^
; strip to bare address% {8 f$ M [+ c' O0 R5 {
full_path := RegExReplace(full_path, “地址: “, “”)
% F) z% Z0 M6 D a ; Just in case – remove all carriage returns (`r)2 h% i$ D) E( D; i
StringReplace, full_path, full_path, `r, , all
! E0 l4 Q7 A, F& o" \0 i IfInString full_path, \
$ E2 p- J# {' W+ N& I! E {
( Q+ x+ I5 G3 }- s4 m Run, cmd /K cd /D “%full_path%”/ e: s) Y& K% r- j% Y$ \
}2 c4 k7 k& u- k2 g+ q3 E
else( t3 m5 ?" q& U+ l: l6 z8 x: Y
{+ S, ^( }$ c* Q
Run, cmd /K cd /D “C:\ ”4 M) l3 J J3 v( F4 Y
}4 t8 e; a1 S/ j( M% R1 C
}: t% T* ~% ~5 d
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。" c/ l$ A% h F U+ G# e
这段小代码肯能有两个你需要修改的地方
, o, ?- M. F4 b# n5 b 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键1 _' F2 H# R! R, j8 ?0 Q- Y! ~, B
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “- c2 u, N# H# ]) }" @, |$ `- P
|