此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。% F. b$ b: Y' z9 q7 F1 @9 |7 i
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。# f& ^8 _- l) l0 o) { [, A/ R7 @
方式一:8 B+ _. T: _7 _" y2 b
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
2 V# `1 m; Y ^) E0 `3 Z 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
' A- R4 y0 j1 ^/ c0 o# X HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。. R3 A) N* G7 \+ ?9 O' [- g
方式二:3 m8 k# l% s/ n* I O8 C: ?
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
# T. p; g0 X2 f* H# U9 B SetTitleMatchMode RegEx3 x9 F- X7 H0 E! I- o
return
* j' G% G: J# L9 {1 L. W* @ ; Stuff to do when Windows Explorer is open
7 G2 K4 Z \! s4 O2 u5 x5 ^ ;: f( b9 ~0 B# i# u3 b4 \+ R7 Z
#IfWinActive ahk_class ExploreWClass|CabinetWClass, h/ ]3 o/ G9 p- ]6 U
; open ‘cmd’ in the current directory$ y6 w! d6 o% ?- t' C
;
! P/ M2 B/ v; ^2 l/ I# d$ | #c::/ Z9 t8 h7 K/ G1 `% ^: b
OpenCmdInCurrent()
: {5 c) X% V8 s7 V4 ?: Q return% }+ {" ]- g5 H: A
#IfWinActive
+ s( g2 N$ S; ?0 R ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.$ z' h$ R% `6 \
; Note: expecting to be run when the active window is Explorer.0 q1 F2 z5 o/ P8 f
;; W `. e( B6 Q
OpenCmdInCurrent()" B0 q2 f, k( S9 n+ P
{1 S2 `* F7 A9 E& Z# n$ u
; This is required to get the full path of the file from the address bar
& C/ ~3 Q3 ~6 B7 U WinGetText, full_path, A
, X# ^* o# O. ^- I2 _ ; Split on newline (`n)7 F+ y- a/ f+ z n6 `
StringSplit, word_array, full_path, `n
! f: ~/ @5 m. [' s ; Take the first element from the array# W+ A4 k5 o. `$ A. M7 Q& Z
full_path = %word_array1%
: ~5 F. J+ a* n+ S+ _0 ? ; strip to bare address
4 n8 H$ ?8 Q$ q full_path := RegExReplace(full_path, “地址: “, “”)
& g ]8 n! G) ]" | ; Just in case – remove all carriage returns (`r)# L. x! C. d/ H3 E/ L, [1 Y, s
StringReplace, full_path, full_path, `r, , all
6 y! Y6 c+ s. U: l* ~! I' a } IfInString full_path, \% X' w7 \% }. ~2 } s; S# s5 ^
{
6 n5 \9 N% o5 y Run, cmd /K cd /D “%full_path%”
1 A1 K' p; n$ d; A# L }3 @- [5 N' {2 I6 _* _' C
else( {; |+ S3 D7 F! B+ c5 m
{
3 U/ z% L ^6 E! Q Run, cmd /K cd /D “C:\ ”5 f6 L. U& K9 i- {( W
}
! j h! j) ^& c' A; _ }7 T% b5 Y1 |4 B2 U( K+ n
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。+ z1 s/ E( W: k, E
这段小代码肯能有两个你需要修改的地方
+ O3 P1 F2 h7 j& g/ R' k3 Z1 K 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键* Q7 Z% Q9 [& z8 K" z. K
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “' q. `1 i, l. e L: ?
|