此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。; Q9 S7 @" G* g2 Y/ `7 r) n
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
8 y a0 G6 _4 X* q6 G 方式一:
( P& n h' Y! {9 _) U; ^/ P* Q 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,7 x# ?; w3 n" b6 F' w8 b
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
G2 b# g5 ]1 s$ t" A! s HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。4 M) f1 c7 H) d" b
方式二:
7 ~) X$ B5 ~6 \ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
( O: d4 F# y1 E SetTitleMatchMode RegEx
% w9 n2 k6 H v return
$ K. ?- |' K6 X1 v/ C ; Stuff to do when Windows Explorer is open" @) ~) o: @: R6 H9 k& ~+ f) @
;$ P( ?: ~; I7 o* j/ P# d; g' R& o
#IfWinActive ahk_class ExploreWClass|CabinetWClass- \0 s5 I) v2 T7 U8 u; N0 i6 s
; open ‘cmd’ in the current directory
( g( _: T* q4 K- S" K2 z4 }' K ;2 ~7 g: l" H/ N$ \- G* K0 o) O
#c::
) G0 D. n! c- H7 W7 Y* {5 C OpenCmdInCurrent()
+ u0 J0 ] l! ~ return# w, f0 ]# @2 |1 O3 F3 d
#IfWinActive
9 S# R) T2 d, {. F1 M; q. G ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
$ M0 E( e9 `5 H, L8 C* h ; Note: expecting to be run when the active window is Explorer.
) u) B, D, P4 I( c2 X4 ~, ~ ;* n# ~+ l* q' V
OpenCmdInCurrent()
0 {5 Q2 m! v& x+ L0 e {
7 P! k& u7 a2 F ; This is required to get the full path of the file from the address bar3 S: F; E8 C& P1 e! _
WinGetText, full_path, A v2 h( ]+ P! d+ }8 w0 [4 J
; Split on newline (`n)2 N. u1 j6 j$ a' F' s, g; |
StringSplit, word_array, full_path, `n
" o8 t0 s8 V# J+ O1 E ; Take the first element from the array
% N r/ ]4 G/ E. s1 A p full_path = %word_array1%
9 Q( B5 ]: b& r! [, p8 C8 _* C ; strip to bare address( V U' g% o! }, h0 \3 y
full_path := RegExReplace(full_path, “地址: “, “”)
) ]/ V* t. ~" i/ U ; Just in case – remove all carriage returns (`r)
3 Z! _1 k) B" P4 L- { StringReplace, full_path, full_path, `r, , all6 V' Z5 o' U) V8 A/ T
IfInString full_path, \' |0 {( ]7 \9 N$ t, A
{
& D8 S. p% {1 z Run, cmd /K cd /D “%full_path%”
* r# O4 g7 ], Z. ^ }0 |+ o2 x$ U! r( @
else5 M& J4 C7 g# U
{
7 p( D W" P9 z6 w Run, cmd /K cd /D “C:\ ”
" V k4 [3 F/ C- E }! v, O, W; [" e5 c$ M6 b
}
4 O% R1 J: e3 u2 K$ { 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
* _" `& S0 A& X. f7 t2 H 这段小代码肯能有两个你需要修改的地方
" v4 @' w& m9 P7 n" l9 O( f 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
, R. z- F: N9 Z4 E9 f 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “4 m# |$ e4 B8 v# B4 z9 @4 c
|