Automation 最佳自动热键宏?

Automation 最佳自动热键宏?,automation,macros,Automation,Macros,我对Windows宏使用自动热键。我通常使用它来定义启动/关注特定应用程序的热键,以及将即时电子邮件发送到待办事项列表中的热键。我还有一个紧急事件,它杀死了我所有占用大量内存的应用程序(Outlook、Firefox等) 那么,有谁有好的AHK宏可以分享吗?自动热键论坛中有很多好的宏: 有多好?这取决于你想要/需要什么。非常简单和有用的代码片段: SetTitleMatchMode RegEx ; ; Stuff to do when Windows Explorer is open ; #I

我对Windows宏使用自动热键。我通常使用它来定义启动/关注特定应用程序的热键,以及将即时电子邮件发送到待办事项列表中的热键。我还有一个紧急事件,它杀死了我所有占用大量内存的应用程序(Outlook、Firefox等)


那么,有谁有好的AHK宏可以分享吗?

自动热键论坛中有很多好的宏:


有多好?这取决于你想要/需要什么。

非常简单和有用的代码片段:

SetTitleMatchMode RegEx ;
; Stuff to do when Windows Explorer is open
;
#IfWinActive ahk_class ExploreWClass|CabinetWClass
    ; create new folder
    ;
    ^!n::Send !fwf

    ; create new text file
    ;
    ^!t::Send !fwt

    ; open 'cmd' in the current directory
    ;
    ^!c::
        OpenCmdInCurrent()
    return
#IfWinActive

; Opens the command shell 'cmd' in the directory browsed in Explorer.
; Note: expecting to be run when the active window is Explorer.
;
OpenCmdInCurrent()
{
    WinGetText, full_path, A  ; This is required to get the full path of the file from the address bar

    ; Split on newline (`n)
    StringSplit, word_array, full_path, `n
    full_path = %word_array1%   ; Take the first element from the array

    ; Just in case - remove all carriage returns (`r)
    StringReplace, full_path, full_path, `r, , all  
    full_path := RegExReplace(full_path, "^Address: ", "") ;

    IfInString full_path, \
    {
        Run, cmd /K cd /D "%full_path%"
    }
    else
    {
        Run, cmd /K cd /D "C:\ "
    }
}

我一直使用这个,通常是为了快速访问MySQL命令行


;我的“开始”菜单中有这个,这样我在重新启动电脑后戴上耳机时就不会弄坏耳朵

sleep, 5000
SoundSet, 1.5 ; really low volume

我使用自动热键创建新的Outlook对象

);Win+Shift+M=新电子邮件

#+m::  Run "mailto:"
);展望

#^M::  Run "%ProgramFiles%\Microsoft Office\Office12\OUTLOOK.EXE" /recycle
);Win+Shift+A=创建新日历约会

#+A::  Run "%ProgramFiles%\Microsoft Office\Office12\OUTLOOK.EXE"/c ipm.appointment
);Win+Shift+T=创建新任务 ; Win+Shift+K=新任务

#+T::  Run "%ProgramFiles%\Microsoft Office\Office12\OUTLOOK.EXE"/c ipm.task
#+K::  Run "%ProgramFiles%\Microsoft Office\Office12\OUTLOOK.EXE"/c ipm.task

在所选文本/单词上添加周围引号
在编写电子邮件或编写代码时非常有用

双击单词,点击Win+X,在周围加上引号

; Win + X
#x:: ; Attention:  Strips formatting from the clipboard too!
Send ^c
clipboard = "%clipboard%"
; Remove space introduced by WORD
StringReplace, clipboard, clipboard,%A_SPACE%",", All
Send ^v
return

这里有一个简单的片段,可以使用鼠标按钮快速关闭当前窗口

这是您在Windows中最常执行的操作之一,您会惊讶地发现,不再需要拍摄小X,可以节省大量时间。使用5键鼠标,我发现这是对“前进”按钮的非常有用的重新分配

考虑到使用选项卡式文档(如web浏览器)的程序,这里有一个更全面的版本:

;-----------------------------------------------------------------------------
; Bind Mouse Button 5 to Close Tab / Close Window command
;-----------------------------------------------------------------------------

; Create a group to hold windows which will use Ctrl+F4 instead of Alt+F4
GroupAdd, CtrlCloseGroup, ahk_class IEFrame             ; Internet Explorer
GroupAdd, CtrlCloseGroup, ahk_class Chrome_WidgetWin_0  ; Google Chrome
; (Add more programs that use tabbed documents here)
Return

; For windows in above group, bind mouse button to Ctrl+F4
#IfWinActive, ahk_group CtrlCloseGroup
  XButton2::
    SendInput {Ctrl Down}{F4}{Ctrl Up}
    Return
#IfWinActive  

; For everything else, bind mouse button to Alt+F4
#IfWinActive
  XButton2::
    SendInput {Alt Down}{F4}{Alt Up}
    Return
#IfWinActive  

; In FireFox, bind to Ctrl+W instead, so that the close command also works
; on the Downloads window.
#IfWinActive, ahk_class MozillaUIWindowClass
  XButton2::
    SendInput {Ctrl Down}w{Ctrl Up}
    Return
#IfWinActive
Visual Studio 2010不容易添加到上面的
CtrlCloseGroup
,因为它的窗口类/标题不容易预测(我认为)。下面是我用来处理它的代码段,包括两个附加的有用绑定:

SetTitleMatchMode, 2  ; Move this line to the top of your script

;-----------------------------------------------------------------------------
; Visual Studio 2010
;-----------------------------------------------------------------------------

#IfWinActive, Microsoft Visual Studio

  ; Make the middle mouse button jump to the definition of any token
  MButton::
    Click Left  ; put the cursor where you clicked
    Send {Shift Down}{F2}{Shift Up}
    Return

  ; Make the Back button on the mouse jump you back to the previous area
  ; of code you were working on.
  XButton1::
    Send {Ctrl Down}{Shift Down}{F2}{Shift Up}{Ctrl Up}
    Return

  ; Bind the Forward button to close the current tab
  XButton2::
    SendInput {Ctrl Down}{F4}{Ctrl Up}
    Return

#IfWinActive

我还发现,在Outlook中,将ALT+1、ALT+2等映射到我编写的宏非常有用,这些宏将当前选定的邮件移动到特定文件夹(例如“个人文件”、“工作文件”等),但这有点复杂。

下面是一个简单但有用的脚本:

^SPACE::  Winset, Alwaysontop, , A

使用CTRL+Space可将任何窗口设置为始终位于顶部。

修复将文件复制到FTP服务器时出现的问题,即“确认文件替换”对话框顶部出现“复制”对话框(非常烦人):

一个用于停用无用的Caps lock钥匙:

Capslock::
return
CTRL+shift+c将光标下方的颜色复制到剪贴板(十六进制)

在活动字段中写入您的电子邮件地址(Win key+m)


我必须添加两行代码才能让这个脚本在Win7中使用AHK 1.048.05:[1]SetTitleMatchMode正则表达式工作;在自动运行部分[2]的脚本顶部,完整路径:=RegExReplace(完整路径“^Address:”,”);strip to bare address我是一个自动热键脚本新手,在执行Leftium的修复程序时遇到了问题,新命令将转到哪行?当我点击^时,这在我的平台上不起作用!n和上面的其他命令列表…我不知道发生了什么查看此链接似乎不再工作:-/vscode默认情况下会执行此操作。只需选择单词并按引号。是代码的扩展版本,它也适用于所有符号(和字符),例如括号、方括号、单引号。。。它非常实用。这是我最喜欢的AHK脚本,它非常方便节省时间。我很高兴你写了这篇文章,非常感谢。
SetTimer, FocusOnWindow, 500
return

FocusOnWindow:
IfWinExist, Confirm File Replace
    WinActivate
return
Capslock::
return
^+c::
MouseGetPos,x,y
PixelGetColor,rgb,x,y,RGB
StringTrimLeft,rgb,rgb,2
Clipboard=%rgb%
Return
#m::
Send, my@email.com{LWINUP}
Sleep, 100
Send, {TAB}
return