此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。+ f9 [5 M$ [; w/ I
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。( h# v+ U) g; a5 |/ T
方式一:
- [+ a2 [% H0 d 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
" ]0 M+ l, c" h6 O4 s 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和! e$ F( G7 I5 S
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。: q |/ \: L& D5 r( B
方式二:
, z. \" i2 ^, j+ t# R% V3 e 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:. J" H4 W. f) b: g0 f. J
SetTitleMatchMode RegEx
9 T$ }+ t0 _2 `, Y% a7 V return2 b d$ D. l$ X, v( g, `( o
; Stuff to do when Windows Explorer is open
* C% K$ u- e/ @) [1 ]+ v ;
: C, d. ~+ g; n8 I8 x. I: s) w5 o #IfWinActive ahk_class ExploreWClass|CabinetWClass
' q) E' \# i* Q ; open ‘cmd’ in the current directory
. b" l- A) d, f1 s" u$ A/ w ; L3 m: b. W8 T" q7 g* Z
#c::
: f: M c- Z# t: K) d1 ] OpenCmdInCurrent()
; g2 d% C: P2 E, P* D# e# o6 L6 ]5 y return
: _+ Q: E- p$ k" M' e* @ O #IfWinActive
% Q9 O: P b8 t* [3 b; |0 k' e! R/ T ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
" S: L# L; K( I" E+ k ; Note: expecting to be run when the active window is Explorer.
* j9 M* Y* R( B0 x0 m4 i6 U. B ;
- x x& Z. Y! J+ x) V2 M OpenCmdInCurrent(); ]7 j7 R% A( K" a
{$ y; H6 H4 E8 f% |! t5 F
; This is required to get the full path of the file from the address bar
0 s: C9 ]3 r5 H WinGetText, full_path, A9 W! ~8 \% T$ B; D
; Split on newline (`n)/ b: o/ g' y9 e- ~3 m$ |
StringSplit, word_array, full_path, `n
1 ~9 |7 O" |) Z w ; Take the first element from the array5 {! { Y& h f
full_path = %word_array1%
4 _& O. s% Q+ ^, S) ^5 ~2 t ; strip to bare address% y/ J" z+ L! |( \: p$ R/ g; J
full_path := RegExReplace(full_path, “地址: “, “”)
0 z" A7 P: `/ L# [5 H ; Just in case – remove all carriage returns (`r)! ]( ~7 R; W% p# G
StringReplace, full_path, full_path, `r, , all, @1 x0 ^( Q% k! d( U1 a& ^" s
IfInString full_path, \/ Y% G( u/ \; h7 d5 h5 }. ~
{
! \! N9 m2 I! R! u P Run, cmd /K cd /D “%full_path%”
$ e+ D+ b* J" q }2 B8 F+ u5 \; t/ X+ n# j# C
else
+ q9 p" K3 b$ L8 k& _% H4 k {: y) |/ W4 b) v% V3 t' p. @
Run, cmd /K cd /D “C:\ ”
8 v: E0 \3 O7 o/ w+ K" m' E @& z }
/ `& _7 w# @, L# x4 M8 N }1 W- d/ Z) d0 N' X0 d
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。. {; b7 F( ]# d1 l0 W
这段小代码肯能有两个你需要修改的地方
- E! v7 W0 C" c* z: l' N 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
5 I c/ G1 \$ n 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “5 }7 _: L* E( w i" L) i F6 m+ n6 s
|