最好的AutoHotKey宏?

lee*_*man 21 macros automation

我使用AutoHotKey for Windows宏.最常见的是我用它来定义启动/聚焦特定应用程序的热键,以及一个用于将即时电子邮件消息发送到我的待办事项列表的热键.我还有一个紧急的应用程序可以杀死所有我占用大量内存的应用程序(Outlook,Firefox等).

那么,有没有人有任何好的AHK宏可以共享?

Eli*_*sky 14

非常简单实用的片段:

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:\ "
    }
}
Run Code Online (Sandbox Code Playgroud)


Pet*_*der 9

在所选文本/单词上添加周围的引号在
编写电子邮件或编码期间有用...

Doubleclick单词,点击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
Run Code Online (Sandbox Code Playgroud)


Eva*_*ack 7

这是一个如此简单但有用的脚本:

^SPACE::  Winset, Alwaysontop, , A
Run Code Online (Sandbox Code Playgroud)

使用CTRL + Space将任何窗口始终设置在顶部.


Bår*_*ård 6

; 我在开始菜单中有这个,以便在重新启动计算机后戴上耳机时不会毁了我的耳朵

sleep, 5000
SoundSet, 1.5 ; really low volume
Run Code Online (Sandbox Code Playgroud)


Pet*_*der 5

我使用 AutoHotKey创建新的Outlook对象

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

#+m::  Run "mailto:"
Run Code Online (Sandbox Code Playgroud)

; 外表

#^M::  Run "%ProgramFiles%\Microsoft Office\Office12\OUTLOOK.EXE" /recycle
Run Code Online (Sandbox Code Playgroud)

; Win+Shift+A = 创建新的日历约会

#+A::  Run "%ProgramFiles%\Microsoft Office\Office12\OUTLOOK.EXE"/c ipm.appointment
Run Code Online (Sandbox Code Playgroud)

; 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
Run Code Online (Sandbox Code Playgroud)


rka*_*rer 5

这是一个非常简单的代码片段,可以使用鼠标按钮快速关闭当前窗口。

这是您在 Windows 中最常执行的操作之一,您会惊讶地发现,由于不再需要瞄准那个小 X,您节省了多少时间。使用 5 键鼠标,我发现这是一个非常有用的重新分配功能“前进”按钮。

#IfWinActive  ;Close active window when mouse button 5 is pressed
  XButton2::
    SendInput {Alt Down}{F4}{Alt Up}
    Return
#IfWinActive  
Run Code Online (Sandbox Code Playgroud)

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

;-----------------------------------------------------------------------------
; 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
Run Code Online (Sandbox Code Playgroud)

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
Run Code Online (Sandbox Code Playgroud)

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


scu*_*ffe 4

AutoHotKey 论坛中有很多好的内容:

http://www.autohotkey.com/forum/forum-2.html&sid=8149586e9d533532ea76e71e8c9e5b7b

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