此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。' O% K+ C `0 ^# q7 r# F
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
& h$ f! Q- K* i/ m& f 方式一:
5 o, b6 b& B4 \$ x 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,9 w8 o7 ~5 g5 X2 U$ A. p1 p: v
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
1 s9 V2 D7 _* D HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
# D/ q( U" q% X& _2 A 方式二:
. U# p$ L+ ]/ R( T; M, C4 Y/ P2 n 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:% _9 x5 p* t$ ^2 p
SetTitleMatchMode RegEx
/ K) {3 `1 X r return! f( B( _+ M7 Z' ?' t1 w2 y& ^8 {
; Stuff to do when Windows Explorer is open3 D. }" @) F) ]! f5 a
;7 Z" R9 m3 k o8 O
#IfWinActive ahk_class ExploreWClass|CabinetWClass
6 [+ S; Q+ @0 e! J ; open ‘cmd’ in the current directory
- a4 ~4 B0 Z* p r- R: W/ Q, |- j7 [ ;
" R( H# g4 B+ `2 C1 ^% _4 g P# S #c::
) d! ~, x: u: f2 Y5 Z OpenCmdInCurrent()
, L) s8 [6 ? S" T! L0 L$ g return
/ \( K) ]' }5 c ~* C #IfWinActive
; o. m' x8 E3 p5 M4 M [% a5 b ; Opens the command shell ‘cmd’ in the directory browsed in Explorer., b: _' _- H; _( j5 n
; Note: expecting to be run when the active window is Explorer.. j: [/ ]1 G) J. s0 B- I- |
;4 E: f0 y" Y, B- l0 y6 {9 e N
OpenCmdInCurrent()' Q+ ]6 K% `7 U
{
8 d! l/ X' \% |1 M ; This is required to get the full path of the file from the address bar
# E3 [) H2 X# {; O WinGetText, full_path, A/ L( x- U, B9 I% A7 b; ~+ V
; Split on newline (`n)
& ~% u) R' W* @0 @ StringSplit, word_array, full_path, `n
& a$ w' H! l, c0 n ; Take the first element from the array$ ]' |) R9 j2 e/ n, p
full_path = %word_array1%
3 O) s0 M: S' }8 s5 X0 Z4 q. l, b ; strip to bare address& u% t$ c d1 y4 {
full_path := RegExReplace(full_path, “地址: “, “”)
! p- e/ _$ R% H3 i; N8 e ; Just in case – remove all carriage returns (`r)( m% ^( o2 j& |
StringReplace, full_path, full_path, `r, , all
$ [1 @: ?2 W8 l, y+ l* {, b IfInString full_path, \
- E" O; N1 M9 R' n* S1 q {8 S1 m; d+ q A
Run, cmd /K cd /D “%full_path%”* w& d. f% s! W- i6 O
}
8 {! S+ ~) w% t) S3 \1 n else& p" B! B8 Q& @
{
( a! g8 t3 c/ l; p Run, cmd /K cd /D “C:\ ”
* k2 h7 M3 b6 i7 Y }
2 W8 ?+ h B8 k$ G }5 V+ W# c) ]8 H" D. @
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。& l* p7 ?% ]7 z$ u8 u3 p& \2 R2 J
这段小代码肯能有两个你需要修改的地方/ f/ D) \2 W9 A* ?
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键: M. G& J6 K$ ~6 z! {
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
8 A0 u- U4 y X, O7 y0 T |